Module: SimpleAccessControl

Defined in:
lib/simple_access_control.rb

Overview

SimpleAccessControl

Acknowledgements: I give all credit to Ezra and Technoweenie for their two plugins which inspired the interface design and a lot of the code for this one.

SimpleAccessControl is a streamlined, intuitive authorisation system. It derives heavily from acl_system2 and has made clear some problems which plagued the author when first using it. Some fixes to acl_system2’s design:

* a normal Rails syntax:
      access_rule 'admin', :only => :index
      access_rule '(moderator || admin)', :only => :new
* error handling for helper methods (permit? bombs out with current_user == nil)
* one-line parser, easy to replace or alter
* proper before_filter usage, meaning access rules are parsed only when needed
* no overrideable default (which I found counter-intuitive in the end)

Also, it has two methods, access_control and permit?, for those moving from acl_system2.

But, let me stress, everyone likes a slightly different system, so this one may not be your style. I find it synchronises very well with the interface of Acts as Authenticated (even though I have modified it so much that it’s now called Authenticated Cookie).

Defined Under Namespace

Modules: ClassMethods Classes: AccessControlHandler

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/simple_access_control.rb', line 26

def self.included(base)
  base.extend(ClassMethods)
  if base.respond_to?(:helper_method)
    base.send :helper_method, :restrict_to
    base.send :helper_method, :has_permission?
    base.send :helper_method, :permit?
  end
end