Re: Controller filter parameters

Eloy Duran
Mon, 02 Nov 2009 14:06:56 -0000

I assume you''re looking for a good way to implement authorization
rules, in which case you might want to take a look at the following
plugin: http://github.com/Fingertips/authorization-san
And checkout this rails template for more examples on how to use it:
http://github.com/Fingertips/rails-template

HTH,
Eloy

On Nov 2, 2009, at 2:19 PM, Rodrigo Rosenfeld Rosas wrote:

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