say in my application controller, I have a before_filter that gets fired, loads some @instance_variables that I will use in my application layout file.
is it possible to load data based on the action that will be re开发者_如何转开发ndered? If yes, how can I figure out the action that is about to be called?
You could either split them up in separate filters.
before_filter :task_show_index, :only => [:index, :show]
before_filter :task_create, :only => :create
or you could read from params
case params[:action]
when "show"
# Do something
when "create"
#Do something else
end
精彩评论