Sha256: 9d0eaf9baab5109bb4c1b0c00b366765a2150b3611e58734f6312b7bdacc1c15
Contents?: true
Size: 905 Bytes
Versions: 13
Compression:
Stored size: 905 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A form object to create or update scopes. class ScopeForm < Form include TranslatableAttributes translatable_attribute :name, String attribute :organization, Decidim::Organization attribute :code, String attribute :parent_id, Integer attribute :scope_type_id, Integer mimic :scope validates :name, translatable_presence: true validates :organization, :code, presence: true validate :code, :code_uniqueness alias organization current_organization def scope_type Decidim::ScopeType.find_by(id: scope_type_id) if scope_type_id end private def code_uniqueness return unless organization return unless organization.scopes.where(code:).where.not(id:).any? errors.add(:code, :taken) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems