Class: Caboose::Permission

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/caboose/permission.rb

Class Method Summary collapse

Class Method Details

.allow(role_id, resource, action) ⇒ Object



9
10
11
12
13
14
15
# File 'app/models/caboose/permission.rb', line 9

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