Sha256: 340a3828feb007621d1b8b4d0cdf5e0ec95521c847c971fc6b1b68456b0be7bd
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module Authz class BusinessProcess < ApplicationRecord # Validations # ========================================================================== validates :code, presence: true, uniqueness: true, format: { with: /\A[a-z][a-z0-9]*(_[a-z0-9]+)*\z/, message: 'only snake_case allowed' } validates :name, presence: true, uniqueness: true validates :description, presence: true # Callbacks # ========================================================================== before_validation :extract_code_from_name, on: [:create] # Associations # ========================================================================== has_many :business_process_has_controller_actions, class_name: 'Authz::BusinessProcessHasControllerAction', foreign_key: 'authz_business_process_id' has_many :controller_actions, through: :business_process_has_controller_actions has_many :role_has_business_processes, class_name: 'Authz::RoleHasBusinessProcess', foreign_key: 'authz_business_process_id' has_many :roles, through: :role_has_business_processes has_many :role_grants, through: :roles private def extract_code_from_name self.code = name.parameterize(separator: '_') if name.present? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authz-0.0.1.alpha | app/models/authz/business_process.rb |