hi for a few days now I am searching for a solution for this problem: I would like to render multiple actions in a layout. For example: I have in the welcome layout two divs: 1 menubar and a main. the menu bar has his one controller with the action: list and the main has a controller (for example: article_controller.rb) with the action: list. both of the actions I want it to be used when the page is loading but i dont now how. I now i can use <%= yield :layout %> for the main. But then I dont render the menu. can I render the action: list in menu when the page is loaded ? then call the action: list in article... I hope you understand my problem (it was hard to explain :P ) -- 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 -~----------~----~----~----~------~----~------~--~---
Heldop Slippers wrote:> hi > > for a few days now I am searching for a solution for this problem: > > I would like to render multiple actions in a layout. > > For example: > I have in the welcome layout two divs: > 1 menubar and a main. > > the menu bar has his one controller with the action: list > and the main has a controller (for example: article_controller.rb) with > the action: list.use iframes <div id=menubar> <iframe src="<%= url_for :controller=>:blah,:action=>:list %>"></iframe></div> <div id=main> <iframe src="<%= url_for :controller=>:articles,:action=>:list2 %>"></iframe></div> walla. you can style the iframes so they have no border, etc; basically, this is (definitely) the way to go. enjoy shai -- 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 -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld wrote:> Heldop Slippers wrote: >> hi >> >> for a few days now I am searching for a solution for this problem: >> >> I would like to render multiple actions in a layout. >> >> For example: >> I have in the welcome layout two divs: >> 1 menubar and a main. >> >> the menu bar has his one controller with the action: list >> and the main has a controller (for example: article_controller.rb) with >> the action: list. > > use iframes > > <div id=menubar> > <iframe src="<%= url_for :controller=>:blah,:action=>:list %>" >></iframe> > </div> > > <div id=main> > <iframe src="<%= url_for :controller=>:articles,:action=>:list2 %>" >></iframe> > </div> > > walla. you can style the iframes so they have no border, etc; basically, > this is (definitely) the way to go. > > enjoy > shaiTHANXS !! ok well meanwhile I did some thinking and came up with this solution: create a helper method (for example article_helper.rb and create an action (for example "list_article"). in application.rb you put helper :article ok if you now call <%= list_article %> you call the action in article_helper. which solution would be best? and why ? -- 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 -~----------~----~----~----~------~----~------~--~---
> > > ok well meanwhile I did some thinking and came up with this solution: > > create a helper method (for example article_helper.rb and create an > action (for example "list_article"). > in application.rb you put helper :article > > ok if you now call <%= list_article %> you call the action in > article_helper. > > which solution would be best? > and why ? >Sorry for my previous truncated reply! That won''t work well because you can only call render (except partials) once per action. The better way to go with these things is a combination of helpers and partials, eg have a render_menu_bar helper. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:>> >> which solution would be best? >> and why ? >> > > Sorry for my previous truncated reply! > That won''t work well because you can only call render (except > partials) once per action. > > The better way to go with these things is a combination of helpers and > partials, eg have a render_menu_bar helper. > > Fredhehe...yes I tryed it but didn''t work... thanxs though, for the reply -- 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 -~----------~----~----~----~------~----~------~--~---
I suspect what you really want is nested layouts: http://agilewebdevelopment.com/plugins/nested_layouts good luck! Tim Heldop Slippers wrote:> hi > > for a few days now I am searching for a solution for this problem: > > I would like to render multiple actions in a layout. > > For example: > I have in the welcome layout two divs: > 1 menubar and a main. > > the menu bar has his one controller with the action: list > and the main has a controller (for example: article_controller.rb) with > the action: list. > > both of the actions I want it to be used when the page is loading but i > dont now how. > I now i can use <%= yield :layout %> for the main. But then I dont > render the menu. > > can I render the action: list in menu when the page is loaded ? > then call the action: list in article... > > I hope you understand my problem (it was hard to explain :P )-- 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 -~----------~----~----~----~------~----~------~--~---
> I would like to render multiple actions in a layout. > > For example: > I have in the welcome layout two divs: > 1 menubar and a main. > > the menu bar has his one controller with the action: list > and the main has a controller (for example: article_controller.rb) with > the action: list. > > both of the actions I want it to be used when the page is loading but i > dont now how. > I now i can use <%= yield :layout %> for the main. But then I dont > render the menu. > > can I render the action: list in menu when the page is loaded ? > then call the action: list in article... > > I hope you understand my problem (it was hard to explain :P )I don''t think I''d call that rendering multiple "actions," but rather that you have multiple objects you want rendered to the screen. Eventually you''ll have all kinds of things you want drawn to screen that come from multiple objects. It is the job of the action for the controller of the route to instantiate all the objects needed into instance vars which can then be used by views, partials, layouts. Have a look at this article: http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/ It explains techniques for getting data into your layouts. -- gw -- 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 -~----------~----~----~----~------~----~------~--~---