如果您有一个布局在菜单中获取其数据库中的菜单项。 Rails应用程序中的推荐位置在哪里放置该调用并将其分配给布局使用的实例变量?推荐位置为布局存储实例变量
1. @menuitems # exists in application.html.erb
2. @menuitems = MenuItem.find(:all) # code exists somewhere (where should this exist?)
@womble - 是一个的before_filter将是有益的,但我会用这个布局,包括在所有控制器,或者是这个东西,我可以把在application_controller.rb,将孩子控制器和随附视图能够看到该实例变量?