Sha256: a4f19847bbe98deb18552ae70b6a1dc2100b37dce1decbda079e20a638f9aa07

Contents?: true

Size: 483 Bytes

Versions: 821

Compression:

Stored size: 483 Bytes

Contents

class Caboose::Permission < ActiveRecord::Base
  self.table_name = "permissions"
  #has_and_belongs_to_many :roles
  has_many :role_permissions
  has_many :roles, :through => :role_permissions  
  attr_accessible :action, :resource
  
  def self.allow(role_id, resource, action)    
    role = Role.find(role_id)
    perm = Permission.where(:resource => resource, :action => action).first
    return if role.nil? || perm.nil?
    role.permissions.push(perm)
    role.save
  end
end

Version data entries

821 entries across 821 versions & 1 rubygems

Version Path
caboose-cms-0.9.99 app/models/caboose/permission.rb
caboose-cms-0.9.98 app/models/caboose/permission.rb
caboose-cms-0.9.97 app/models/caboose/permission.rb
caboose-cms-0.9.96 app/models/caboose/permission.rb
caboose-cms-0.9.95 app/models/caboose/permission.rb
caboose-cms-0.9.94 app/models/caboose/permission.rb
caboose-cms-0.9.93 app/models/caboose/permission.rb
caboose-cms-0.9.92 app/models/caboose/permission.rb
caboose-cms-0.9.91 app/models/caboose/permission.rb
caboose-cms-0.9.90 app/models/caboose/permission.rb
caboose-cms-0.9.89 app/models/caboose/permission.rb
caboose-cms-0.9.88 app/models/caboose/permission.rb
caboose-cms-0.9.87 app/models/caboose/permission.rb
caboose-cms-0.9.86 app/models/caboose/permission.rb
caboose-cms-0.9.85 app/models/caboose/permission.rb
caboose-cms-0.9.84 app/models/caboose/permission.rb
caboose-cms-0.9.83 app/models/caboose/permission.rb
caboose-cms-0.9.82 app/models/caboose/permission.rb
caboose-cms-0.9.81 app/models/caboose/permission.rb
caboose-cms-0.9.80 app/models/caboose/permission.rb