ruby on rails - What is the best practice for rendering the same thing in two different ways? -


i got - actor - model , relative controller classical show action displays complete list of actors , various information them (e.g. movies they've starred in, etc.).

now, i'd retrieve exact same information need show action, show them in partial different style, since partial - _search_results - has used create small "search-as-you-type" box.

imagine show action finder window displaying folders , files , partial dropdown list appears when search on spotlight.

of course stay dry possible , i'm wondering best practice this, while not repeating code in actors_controller, since information needed partial same show action produces show view.

thanks.

edit (n.b.) of course want partial rendered inside controller, because don't want application layout shown in search result box!

the classic advice on stick information assembly in model, can accessed multiple controller actions without duplication. named scopes , make of easy do.

http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -