Sha256: fc2759b12720d4cd41889965c413af33ae33868cd14fd54d36c8540f6bbcdbcd
Contents?: true
Size: 932 Bytes
Versions: 11
Compression:
Stored size: 932 Bytes
Contents
class Permission < ApplicationRecord # REFERENCES has_many :permission_roles, dependent: :destroy, inverse_of: :permission has_many :roles, through: :permission_roles, inverse_of: :permissions belongs_to :predicate, inverse_of: :permissions belongs_to :action, inverse_of: :permissions belongs_to :target, inverse_of: :permissions # VALIDATIONS validates :predicate_id, presence: true, uniqueness: {scope: [:action_id, :target_id]} validates :action_id, presence: true validates :target_id, presence: true def display_name pr = (I18n.t "permissions.predicates.#{predicate.name}", default: predicate.name.titleize rescue nil) a = (I18n.t "permissions.actions.#{action.name}", default: action.name.titleize rescue nil) m = (I18n.t "activerecord.models.#{target.name}", count: 2, default: target.name.titleize rescue nil) [ pr, a, m ].join(" ") end end
Version data entries
11 entries across 11 versions & 1 rubygems