Hi! I’m Matheus
Here’s the thing: I want to use :before_filter with the option :only
using a function that returns a array of actions.
For example:
:before_filter :authorization, :only => :actions_i_want
def actions_i_want
[:new, :destroy, :create]
end
Please, if anyone know how to fix this, or another way to do it, help
me!!
Thanks
On 13 Jan 2011, at 01:34, Matheus C. [email protected] wrote:
[:new, :destroy, :create]
end
Please, if anyone know how to fix this, or another way to do it, help
me!!
Don’t think rails supports this. You could always drop the :only option
and then check the action yourself from your filter method
Fred
On Wednesday, January 12, 2011 8:34:15 PM UTC-5, Matheus C. wrote:
def actions_i_want
[:new, :destroy, :create]
end
Please, if anyone know how to fix this, or another way to do it, help
me!!
Thanks
Like Frederick said, I’m pretty sure Rails doesn’t support this. Try his
suggestion, eg:
before_filter :authorization
def authorization
return unless %w(new destroy create).include? params[:action]
…the rest of your code…
end