Module: ActiveRecordPermissions

Defined in:
lib/active_scaffold/active_record_permissions.rb

Overview

This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.

You may define instance methods in the following formats:

def #{column}_authorized_for_#{action}?
def #{column}_authorized?
def authorized_for_#{action}?

Your methods should allow for the following special cases:

* cron scripts
* guest users (or nil current_user objects)

Defined Under Namespace

Modules: ModelUserAccess, Permissions

Constant Summary collapse

@@current_user_method =
:current_user
@@default_permission =
true

Class Method Summary collapse

Class Method Details

.current_user_methodObject



17
# File 'lib/active_scaffold/active_record_permissions.rb', line 17

def self.current_user_method; @@current_user_method; end

.current_user_method=(v) ⇒ Object

ActiveRecordPermissions needs to know what method on your ApplicationController will return the current user, if available. This defaults to the :current_user method. You may configure this in your environment.rb if you have a different setup.



16
# File 'lib/active_scaffold/active_record_permissions.rb', line 16

def self.current_user_method=(v); @@current_user_method = v; end

.default_permissionObject



23
# File 'lib/active_scaffold/active_record_permissions.rb', line 23

def self.default_permission; @@default_permission; end

.default_permission=(v) ⇒ Object

Whether the default permission is permissive or not If set to true, then everything’s allowed until configured otherwise



22
# File 'lib/active_scaffold/active_record_permissions.rb', line 22

def self.default_permission=(v); @@default_permission = v; end