Controller filter parameters

Rodrigo Rosenfeld Rosas
Mon, 02 Nov 2009 13:19:13 -0000

Today I was writing an authentication filter to my controllers that
needed some parameters. That is what I did:

def self.verify_permission(permission, options={})
   before_filter {|controller| controller.verify_permission(permission,
options)}
end
def verify_permission(permission, options)
   # actual authentication code goes here
end

And check the permissions with, say:

verify_permission :manage_simulation, :simulation => 1 #just ficticious

Is it possible to do it with Rails directly with some syntax like the below?

before_filter :verify_permission, :parameters => [:manage_simulation,
{:simulation => 1}], :except => [:login]

If not, it is not complicated to implement, so is there any reasons why
this would be a bad idea?

Thanks in advance,

Rodrigo.