Sha256: 3710d4e6edf8ceed61b6eca457d24f916380584401ab4baaf27711ae5b0108d4

Contents?: true

Size: 824 Bytes

Versions: 57

Compression:

Stored size: 824 Bytes

Contents

module Cmor::Rbac
  class RolePermission < ActiveRecord::Base
    # associations
    belongs_to :permission
    belongs_to :role
    has_many :user_roles, through: :role
    has_many :users, through: :user_roles

    if Rails.version >= '5.0.0'
      belongs_to :enabled_role, -> { enabled }, foreign_key: 'role_id', class_name: 'Cmor::Rbac::Role', optional: true
    else
      belongs_to :enabled_role, -> { enabled }, foreign_key: 'role_id', class_name: 'Cmor::Rbac::Role'
    end
    has_many :enabled_user_roles, through: :enabled_role, source: :user_roles
    has_many :enabled_users, through: :enabled_user_roles, source: :enabled_role_permissions

    # validations
    validates :permission, presence: true
    validates :permission_id, uniqueness: { scope: :role_id }
    validates :role, presence: true
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
cmor_rbac-0.0.60.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.59.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.58.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.57.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.56.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.55.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.54.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.53.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.52.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.51.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.50.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.49.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.48.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.45.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.44.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.43.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.42.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.41.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.40.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.39.pre app/models/cmor/rbac/role_permission.rb