stffn / declarative_authorization

An unmaintained authorization plugin for Rails. Please fork to support current versions of Rails
MIT License
1.24k stars 230 forks source link

:context=>:foo does not set specified context in nested controller? #128

Closed zachris closed 12 years ago

zachris commented 12 years ago

I'm trying to override context in a nested controller I have similar controllers nested under different namespaces but want to manage only one kind of permission for all.

I have a roles with permissions like this. has_permission_on :foo, :to=>:manage

And a controller that might look like this:

class Bars::FooController

this does not work, it denies permissions for context => :bars_foo

filter_access_to :new, :create, :require =>:manage, :context=>:foo

but this DOES work!?

filter_access_to :index, :require =>:read, :context=>:foo

Explicitly overriding decl_auth_context works however...

class << self def decl_auth_context :foo end end

[...]

end

Something strange is going on. It works for :read, but not for :new (falling back to default). I can't see the logic behind it...

stffn commented 12 years ago

This sounds strange, indeed. There shouldn't be any difference between the new/create and the index case. Are you sure that there isn't something else wrong? Are those controllers inheriting filter_access_to statements already, for example?