[off-topic] Re: Re: Controller filter parameters

Rodrigo Rosenfeld Rosas
Tue, 03 Nov 2009 10:16:23 -0000

Em 02-11-2009 15:05, Eloy Duran escreveu:
> Hey Rodrigo,
>
>
>> 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''...
>>
>
> I don''t completely follow the explanation of the example, but that
> would probably be easy with authorization-san. It already supports the
> idea of ''role'' on an object.
> In all the projects we have used it, we haven''t found one scenario
> that we couldn''t solve.
>
> class InstitutionsController<  ActionController::Base
>     allow_access :institution_admin do
>       # perform any checks and return truthy or falsy value
>     end
> end
>
I still can''t figure out how would be the complete use case with
authorization-san.

Let me put the examples in more detail. In my project, users have roles,
which have permissions, as usual.

But some roles are attached to some condition. In a role
''institution_admin'', a user should be attached to some
specific existent
institution.

But if a user belongs to ''system_admin'' role, for instance, it
shouldn''t
be attached to any conditions.

I have in User:

has_many :roles, :through => :assignments

And in Assignment, there is ''user_id'',
''role_id'' and an integer
''condition'' that could be null. The roles are fixed and I
check that
condition is filled in correctly depending on the role.

There is a hash that maps the expected condition class to each role.

If you think I could do the same with authorization-san, I would be glad
to see a more in-depth example.

Thank you,

Rodrigo.