module ActiveScaffold

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)

Public Class Methods

autoload_subdir(dir, mod = self, root = File.dirname(__FILE__)) click to toggle source
# File lib/active_scaffold.rb, line 15
def self.autoload_subdir(dir, mod = self, root = File.dirname(__FILE__))
  Dir["#{root}/active_scaffold/#{dir}/*.rb"].each do |file|
    basename = File.basename(file, '.rb')
    mod.module_eval do
      autoload basename.camelcase.to_sym, "active_scaffold/#{dir}/#{basename}"
    end
  end
end
exclude_bridges() click to toggle source
# File lib/active_scaffold.rb, line 81
def self.exclude_bridges
  @@exclude_bridges ||= []
end
exclude_bridges=(bridges) click to toggle source

exclude bridges you do not need, add to an initializer name of bridge subdir should be used to exclude it eg

ActiveScaffold.exclude_bridges = [:cancan, :ancestry]
# File lib/active_scaffold.rb, line 77
def self.exclude_bridges=(bridges)
  @@exclude_bridges = bridges
end
js_config() click to toggle source
# File lib/active_scaffold.rb, line 69
def self.js_config
  @@js_config ||= {:scroll_on_close => :checkInViewport}
end
js_config=(config) click to toggle source
# File lib/active_scaffold.rb, line 65
def self.js_config=(config)
  @@js_config = config
end
js_framework() click to toggle source
# File lib/active_scaffold.rb, line 56
def self.js_framework
  @@js_framework ||=
    if defined? Jquery
      :jquery
    elsif defined? PrototypeRails
      :prototype
    end
end
js_framework=(framework) click to toggle source
# File lib/active_scaffold.rb, line 52
def self.js_framework=(framework)
  @@js_framework = framework
end
root() click to toggle source
# File lib/active_scaffold.rb, line 85
def self.root
  File.dirname(__FILE__) + '/..'
end
set_defaults(&block) click to toggle source
# File lib/active_scaffold.rb, line 89
def self.set_defaults(&block)
  ActiveScaffold::Config::Core.configure(&block)
end