Class: ArPolicyRule

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/ar_policy_rule.rb

Overview

Schema information

Table name: ar_policy_rule : Access policy rules

id                   Integer              id
created_at           Time                 created_at
updated_at           Time                 updated_at
ar_role_id           Object               User role access defined by this rule
permission           Integer              Access permission

ArPolicyRule records define rules for the policy. They define user roles and their permission to view or edit data on site.

Instance Method Summary collapse

Instance Method Details

#cache_clearObject

Clear cache if cache is configured



52
53
54
# File 'app/models/ar_policy_rule.rb', line 52

def cache_clear
  Agile.cache_clear(:ar_site)
end

#validationsObject

Additional validations.



59
60
61
62
63
# File 'app/models/ar_policy_rule.rb', line 59

def validations
  if new_record? && ArPolicyRule.find_by(ar_policy_id: ar_policy_id, ar_role_id: ar_role_id).present?
    errors.add('ar_role_id', I18n.t('agile.already_defined'))
  end
end