Re: Controller filter parameters

Rodrigo Rosenfeld Rosas
Mon, 02 Nov 2009 14:29:01 -0000

Hi Eloy, thank you for your suggestion, but I don''t think it would
satisfy my needs...

In my case, a user has a role that can be attached to some conditions.
For instance, the user ''manager'' has a role
''institution_admin'' only for
institution ''manager_institution''...

But anyway, that was just an example. I was really curious about filters
supporting parameters directly.

Best regards,

Rodrigo.

Em 02-11-2009 14:06, Eloy Duran escreveu:
> 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.
>>