Sha256: 3ada31d2294e0856f1e0f7a581cce3fe1c05436db0bfc60dc281ef8803588a65
Contents?: true
Size: 930 Bytes
Versions: 57
Compression:
Stored size: 930 Bytes
Contents
module Cmor::Rbac class UserRole < ActiveRecord::Base # associations belongs_to :user, class_name: Cmor::Rbac::Configuration.user_class_name, foreign_key: 'user_id', inverse_of: :user_roles belongs_to :role, inverse_of: :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_role_permissions, through: :enabled_role, source: :user_roles, class_name: 'Cmor::Rbac::RolePermission' has_many :enabled_permissions, through: :enabled_role_permissions, class_name: 'Cmor::Rbac::Permission', source: :permission # validations validates :user, presence: true validates :user_id, uniqueness: { scope: :role_id } validates :role, presence: true end end
Version data entries
57 entries across 57 versions & 1 rubygems