So I have a layout (application.rhtml) that contains a list of
categories that are stored within the database. To get retrieve the
list I overwrite the initialize method within the application
controller (application.rb) as such:
def initialize @categories = Category.find(:all, :order => :position)
end
Is this the best way I should be doing this? I don’t want to have
this code in my layout breaking MVC idioms, but is there a more
preferred way in best practice then by doing it this way?
Excellent - I thought about doing it with a before_filter, but again
wasn’t sure. I’ve adjusted the code to use a before_filter instead
and it’s all working great, thanks a lot.
Blaine
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.