Hi I have an application layout, and in it there is a sidebar. What i want to do is put things like tags, newly registered users, recent comments, etc in the sidebar. I am not sure how to do this... What controller does the application layout access instance variables from? I presume you can use the application controller, but am not quite sure how... PJ. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jun 8, 7:21 am, PJAY79 <pjay1...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hi > > I have an application layout, and in it there is a sidebar. What i > want to do is put things like tags, newly registered users, recent > comments, etc in the sidebar. > > I am not sure how to do this... > > What controller does the application layout access instance variables > from? I presume you can use the application controller, but am not > quite sure how... >The controller that is rendering the current action (what other one could it be?). Fred> PJ.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Praveen Jayarajan wrote:> Hi > > I have an application layout, and in it there is a sidebar. What i > want to do is put things like tags, newly registered users, recent > comments, etc in the sidebar. > > I am not sure how to do this... > > What controller does the application layout access instance variables > from? I presume you can use the application controller, but am not > quite sure how... > > PJ.If your site has a global layout it''d be quite normal to have the following lines in application.rb class ApplicationController layout ''application'' before_filter :set_layout_variables def set_layout_variables @stuff = Stuff.find(:all) end end Then all controllers will inherit this before_filter and by default render their output into the layout /app/views/layouts/application.html.erb -- 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 -~----------~----~----~----~------~----~------~--~---
Thank you Matthew, that''s exactly what i needed! Works great :) PJ. On Jun 8, 9:18 pm, Matthew Rudy Jacobs <rails-mailing-l...@andreas- s.net> wrote:> Praveen Jayarajan wrote: > > Hi > > > I have an application layout, and in it there is a sidebar. What i > > want to do is put things like tags, newly registered users, recent > > comments, etc in the sidebar. > > > I am not sure how to do this... > > > What controller does the application layout access instance variables > > from? I presume you can use the application controller, but am not > > quite sure how... > > > PJ. > > If your site has a global layout > it''d be quite normal to have the following lines in application.rb > > class ApplicationController > > layout ''application'' > before_filter :set_layout_variables > > def set_layout_variables > @stuff = Stuff.find(:all) > end > > end > > Then all controllers will inherit this before_filter and by default > render their output into the layout > /app/views/layouts/application.html.erb > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---