I''m not understand how to piece my whole application together. Basically I have a home page for a restaurants website which will display a search facility, a login box, and some stats. Now my first problem is not knowing which controller this should be the layout for, because the only part of this page that would be common to all other pages is the header and that is it: see http://www.eatnewcastle.com/test/layout.htm My second problem is that the login box functionality is part of an account controller, the search box functionality is part of a search controller etc So how can I render partials from all these different controllers in this one layout? I hope this makes sense. Please reply if any aspect is confusing and I will try to explain myself better. Thanks very much! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mfairchi
2006-Nov-26 18:27 UTC
Re: Layouts - how to render partials from multiple controllers
in your view code just prefix the partial template with "controller_name/partial_name" like so: <%= render :partial=>''search/search_box'' %> <%= render :partial=> ''restraunts/menus'' %> hope thats what you were looking for. ~Michael fairchild On Nov 26, 10:11 am, Richard <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m not understand how to piece my whole application together. > > Basically I have a home page for a restaurants website which will > display a search facility, a login box, and some stats. > > Now my first problem is not knowing which controller this should be the > layout for, because the only part of this page that would be common to > all other pages is the header and that is it: seehttp://www.eatnewcastle.com/test/layout.htm > > My second problem is that the login box functionality is part of an > account controller, the search box functionality is part of a search > controller etc So how can I render partials from all these different > controllers in this one layout? > > I hope this makes sense. Please reply if any aspect is confusing and I > will try to explain myself better. Thanks very much! > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Brandt
2006-Nov-26 18:30 UTC
Re: Layouts - how to render partials from multiple controllers
Richard wrote:> I''m not understand how to piece my whole application together. > > Basically I have a home page for a restaurants website which will > display a search facility, a login box, and some stats. > > Now my first problem is not knowing which controller this should be the > layout for, because the only part of this page that would be common to > all other pages is the header and that is it: see > http://www.eatnewcastle.com/test/layout.htm > > My second problem is that the login box functionality is part of an > account controller, the search box functionality is part of a search > controller etc So how can I render partials from all these different > controllers in this one layout? > > I hope this makes sense. Please reply if any aspect is confusing and I > will try to explain myself better. Thanks very much! > >The controller is up to you, as its really just personal preference. I usually use the users controller and a "welcome" action for such things. You can call partials from other controllers as such. render :partial => ''another_controller/partial'' -b --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Richard
2006-Nov-26 18:34 UTC
Re: Layouts - how to render partials from multiple controlle
Brandt wrote:> Richard wrote: >> My second problem is that the login box functionality is part of an >> account controller, the search box functionality is part of a search >> controller etc So how can I render partials from all these different >> controllers in this one layout? >> >> I hope this makes sense. Please reply if any aspect is confusing and I >> will try to explain myself better. Thanks very much! >> >> > The controller is up to you, as its really just personal preference. I > usually use the users controller and a "welcome" action for such > things. You can call partials from other controllers as such. > > render :partial => ''another_controller/partial'' > > -bAh right. Thanks to both of you! This helped. I really didn''t realise it was as simple as that. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Richard wrote:> Brandt wrote:>> render :partial => ''another_controller/partial''> Ah right. Thanks to both of you! This helped. I really didn''t realise it > was as simple as that.Will the other controller control the other partial? -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phlip wrote:> Richard wrote: > > >> Brandt wrote: >> > > >>> render :partial => ''another_controller/partial'' >>> > > >> Ah right. Thanks to both of you! This helped. I really didn''t realise it >> was as simple as that. >> > > Will the other controller control the other partial? > >No, if your partial needs objects, they need to be supplied by the controller/action that is being performed. Components will achieve what I believe you are thinking of, but I really can''t comment on them as I''ve never used them myself. -b --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Brandt wrote:> No, if your partial needs objects, they need to be supplied by the > controller/action that is being performed. Components will achieve what I > believe you are thinking of, but I really can''t comment on them as I''ve > never used them myself.The moral of the Rails story is that a little bit of MVC is still much, much better than none! -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---