Sha256: d395715e3b628b4d97c946acebbc760a8d94a400b181de08ccb77b06276b8755
Contents?: true
Size: 947 Bytes
Versions: 1
Compression:
Stored size: 947 Bytes
Contents
class ActionRole < ActiveRecord::Base belongs_to :role belongs_to :action # this is the key database lookup for checking permissions # returns true if there is at least one of the passed-in role ids # which explicitly permits (i.e. the role has action_role associations) # the specified controller and action def self.permits_access_for(controller, action, role_ids) joins([:role, :action => :controller ]). where("roles.id" => role_ids). where("actions.action_name" => action). where("controllers.controller_name" => controller). exists? end def self.assign_developer_access developer_id = Role.developer_id Action.all.each do |a| find_or_create_by_action_id_and_role_id(a.id, developer_id) end if developer_id end def self.bootstrap_access_for(role) Action.all.each do |a| find_or_create_by_action_id_and_role_id(a.id, role.id) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authengine-0.0.2 | app/models/action_role.rb |