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.38.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.37.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.36.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.35.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.34.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.33.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.32.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.31.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.30.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.29.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.28.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.27.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.26.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.25.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.24.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.22.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.21.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.20.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.19.pre app/models/cmor/rbac/role_permission.rb
cmor_rbac-0.0.18.pre app/models/cmor/rbac/role_permission.rb