On Miércoles, 16 de Junio de 2010 17:46:05 Kristian Hellquist escribió:
> Hi
>
> Im using cancan with active-scaffold by overriding `authorized_for?'.
> However, I must override this method in all controllers for this to
> work.
>
> * I would like to override `authorized_for?' as the default behavior
> for my application.
> * I would like to do this without monkey-patching anything.
Have you tried to override "authorized_for?" in ApplicationController?
>
> I hoped that `Bridges' would be a way of including another
> authorization layer, but Bridges doesn't seem to be capable of doing
> this.
You can do it with Bridge. In the bridge override authorized_for? in
ActiveScaffold::Actions::Core
In init.rb:
ActiveScaffold.bridge "Cancan" do
install do
require File.join(File.dirname(__FILE__), "lib/cancan_bridge.rb")
ActiveScaffold::Actions::Core.module_eval { include
ActiveScaffold::CancanBridge }
end
end
In lib/cancan_bridge.rb:
module ActiveScaffold
module CancanBridge
def authorized_for?(options = {})
[cancan code]
end
end
end
>
> Is monkey patching the only way to change authorization for
> active_scaffold?
>
> Kristian Hellquist
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en.