Sha256: 3bb6a22eec182da6f54b713ce7a057924572647e56cb431368b1e899de8ff56a
Contents?: true
Size: 821 Bytes
Versions: 4
Compression:
Stored size: 821 Bytes
Contents
module Ecm::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: 'Ecm::Rbac::Role', optional: true else belongs_to :enabled_role, -> { enabled }, foreign_key: 'role_id', class_name: 'Ecm::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
4 entries across 4 versions & 1 rubygems