Browse files

Automagically set the filter_access_to to work with namespaced contro…


Context by default is the controller_name.to_sym, however this breaks with the use of namespaced controllers (eg. Admin::FoozlesController)
Instead of taking controller_instance.class.controller_name, this change takes the and gsubs :: into _ so the resulting symbols look like :admin_foozles rather than :foozles

This is a variant to the style implemented in viva-declarative_authorization:
  • Loading branch information...
Mark Connell
Mark Connell committed Oct 20, 2009
1 parent c6ee88e commit 1edc6d0399881c58fcf3325478869727cdbc9be1
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/declarative_authorization/in_controller.rb
@@ -545,7 +545,7 @@ def permit! (contr)
if @filter_block
return contr.instance_eval(&@filter_block)
context = @context || contr.class.controller_name.to_sym
context = @context ||, '_').gsub(/Controller$/, "").underscore.to_sym
object = @attribute_check ? load_object(contr, context) : nil
privilege = @privilege || :"#{contr.action_name}"

0 comments on commit 1edc6d0

Please sign in to comment.