Sha256: 83966bce650d808e56c957611fa0edcd1a36e04e746d39b4a0370d6ae75168ea
Contents?: true
Size: 806 Bytes
Versions: 10
Compression:
Stored size: 806 Bytes
Contents
class CmPermission < ApplicationRecord after_create :create_hidden_permission after_destroy :destroy_hidden_permission validates :action_name, presence: true, uniqueness: { scope: %i[ar_model_name cm_role_id] } def create_hidden_permission if action_name == 'new' CmPermission.where(action_name: 'create', ar_model_name:, cm_role_id:).first_or_create elsif action_name == 'edit' CmPermission.where(action_name: 'update', ar_model_name:, cm_role_id:).first_or_create end end def destroy_hidden_permission if action_name == 'new' CmPermission.where(action_name: 'create', ar_model_name:, cm_role_id:).first&.destroy elsif action_name == 'edit' CmPermission.where(action_name: 'update', ar_model_name:, cm_role_id:).first&.destroy end end end
Version data entries
10 entries across 10 versions & 1 rubygems