Sha256: ddaa4d1ed3b6587ec7c6a8a7c8f177a8c3883ddfb26f53e67152be1bec3ae9ee
Contents?: true
Size: 893 Bytes
Versions: 22
Compression:
Stored size: 893 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 && organization.scopes.where(code: code).where.not(id: id).any? errors.add(:code, :taken) end end end end
Version data entries
22 entries across 22 versions & 2 rubygems