before_filter problem

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

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!!

Don't think rails supports this. You could always drop the :only option and then check the action yourself from your filter method

Fred

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