I want to display the top three schools (in @top_schools array) in my view which is in a column on the left on the site. This is the same for all views and all controllers so naturally it''s in the layout file in the partial _lcol.html.erb The problem is, being in a partial it''s displayed for whatever action it is in. I don''t know where to put it in the controller. Putting it in the index action of the Schools controller only displays the array for that action. How do I make it universal aside from putting the business logic right into the view? <% for school in @top_schools %> <li><%= school.title %></li> <% end %> -- 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 -~----------~----~----~----~------~----~------~--~---
Put it in the application.rb file in the app/controllers directory. On Dec 5, 2007 2:36 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I want to display the top three schools (in @top_schools array) in my > view which is in a column on the left on the site. This is the same for > all views and all controllers so naturally it''s in the layout file in > the partial _lcol.html.erb > > The problem is, being in a partial it''s displayed for whatever action it > is in. I don''t know where to put it in the controller. Putting it in the > index action of the Schools controller only displays the array for that > action. How do I make it universal aside from putting the business logic > right into the view? > > <% for school in @top_schools %> > <li><%= school.title %></li> > <% end %> > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg --~--~---------~--~----~------------~-------~--~----~ 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 tried before. class ApplicationController < ActionController::Base @top_schools = School.find end does not make the @top_schools variable available to the view. -- 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 -~----------~----~----~----~------~----~------~--~---
It likes it in the Application_Helper file. Ellis Berner wrote:> I tried before. > class ApplicationController < ActionController::Base > @top_schools = School.find > end > > does not make the @top_schools variable available to the view.-- 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 -~----------~----~----~----~------~----~------~--~---
On Dec 4, 2007, at 8:06 PM, Ellis Berner wrote:> I want to display the top three schools (in @top_schools array) in my > view which is in a column on the left on the site. This is the same > for > all views and all controllers so naturally it''s in the layout file in > the partial _lcol.html.erb > > The problem is, being in a partial it''s displayed for whatever > action it > is in. I don''t know where to put it in the controller. Putting it > in the > index action of the Schools controller only displays the array for > that > action. How do I make it universal aside from putting the business > logic > right into the view? > > <% for school in @top_schools %> > <li><%= school.title %></li> > <% end %>Have a look at this article for several ideas on how to deal with repeating and unique partials and layouts... http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/ -- def gw acts_as_n00b writes_at(www.railsdev.ws) end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---