Layouts

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 %>

  • <%= school.title %>

  • <% end %>

    Put it in the application.rb file in the app/controllers directory.

    On Dec 5, 2007 2:36 PM, Ellis B. [email protected]
    wrote:

    right into the view?

    <% for school in @top_schools %>

  • <%= school.title %>

  • <% end %>

    Posted via http://www.ruby-forum.com/.


    Ryan B.

    I tried before.
    class ApplicationController < ActionController::Base
    @top_schools = School.find
    end

    does not make the @top_schools variable available to the view.

    It likes it in the Application_Helper file.

    Ellis B. wrote:

    I tried before.
    class ApplicationController < ActionController::Base
    @top_schools = School.find
    end

    does not make the @top_schools variable available to the view.

    On Dec 4, 2007, at 8:06 PM, Ellis B. wrote:

    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 %>

  • <%= school.title %>

  • <% 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