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.119 app/models/caboose/permission.rb
caboose-cms-0.9.118 app/models/caboose/permission.rb
caboose-cms-0.9.117 app/models/caboose/permission.rb
caboose-cms-0.9.116 app/models/caboose/permission.rb
caboose-cms-0.9.115 app/models/caboose/permission.rb
caboose-cms-0.9.114 app/models/caboose/permission.rb
caboose-cms-0.9.113 app/models/caboose/permission.rb
caboose-cms-0.9.112 app/models/caboose/permission.rb
caboose-cms-0.9.111 app/models/caboose/permission.rb
caboose-cms-0.9.110 app/models/caboose/permission.rb
caboose-cms-0.9.109 app/models/caboose/permission.rb
caboose-cms-0.9.108 app/models/caboose/permission.rb
caboose-cms-0.9.107 app/models/caboose/permission.rb
caboose-cms-0.9.106 app/models/caboose/permission.rb
caboose-cms-0.9.105 app/models/caboose/permission.rb
caboose-cms-0.9.104 app/models/caboose/permission.rb
caboose-cms-0.9.103 app/models/caboose/permission.rb
caboose-cms-0.9.102 app/models/caboose/permission.rb
caboose-cms-0.9.101 app/models/caboose/permission.rb
caboose-cms-0.9.100 app/models/caboose/permission.rb