Class: ArPolicy
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ArPolicy
- Defined in:
- app/models/ar_policy.rb
Overview
Schema information
Table name: ar_policy : Access policy declarations
id Integer id created_at Time created_at updated_at Time updated_at name String Unique policy name description String Description for this policy is_default Boolean This is default policy for the site active Boolean Policy is active updated_by Integer updated_by message String Error message when blocked by this policy rules String Policy rules
ArPolicy documents define policies for accessing data on web site. Policies define which user roles (defined in ar_policy_roles table) has no access, can view or edit data (sees CMS menu) on current active web page. Policies can then be applied to individual documents or parts of the site.
Document defined as default, holds top level policy which is inherited by all other policies. Default policy is also used when document has no access policy assigned.
Instance Method Summary collapse
-
#cache_clear ⇒ Object
Clear cache if cache is configured.
-
#is_the_only_default_policy ⇒ Object
There should be only one default policy.
Instance Method Details
#cache_clear ⇒ Object
Clear cache if cache is configured
62 63 64 65 |
# File 'app/models/ar_policy.rb', line 62 def cache_clear Agile.cache_clear(:ar_permission) Agile.cache_clear(:ar_site) end |
#is_the_only_default_policy ⇒ Object
There should be only one default policy.
70 71 72 73 74 75 76 |
# File 'app/models/ar_policy.rb', line 70 def is_the_only_default_policy existing_policy_id = ArPolicy.find_by(ar_site_id: ar_site_id, is_default: true)&.id if is_default && existing_policy_id && existing_policy_id != id errors.add('is_default', I18n.t('agile.already_defined')) end end |