Hello,
I have a model:
review.rb
class Review < ActiveRecord::Base
def self.published
find(:all,
:conditions => “she_published = TRUE and he_published = TRUE
and date_to_be_published <= now()”)
end
end
And a controller:
display_controller.rb
class DisplayController < ApplicationController
def index
@published_reviews = Review.published
end
def show
@review = Review.find(params[:id])
@published_reviews = Review.published
end
def about
@published_reviews = Review.published
end
end
And part of my layout:
display.rhtml
<% for review in @published_reviews %>
<%= link_to review.name, :controller => "display", :action =>
“show”, :id => review.id %>
<% end %>
Right now the only way I can get things to work is to put the line
@published_reviews = Review.published
in each def
Is there a place I can put this line just once so it’s accessible by
the layout, no matter what the action?
Thanks,
Sean