Class: Decidim::Admin::AreaForm

Inherits:
Form
  • Object
show all
Includes:
TranslatableAttributes
Defined in:
app/forms/decidim/admin/area_form.rb

Overview

A form object to create or update areas.

Instance Method Summary collapse

Instance Method Details

#area_typeObject



29
30
31
# File 'app/forms/decidim/admin/area_form.rb', line 29

def area_type
  Decidim::AreaType.find_by(id: area_type_id) if area_type_id
end

#name_uniquenessObject



20
21
22
23
24
25
# File 'app/forms/decidim/admin/area_form.rb', line 20

def name_uniqueness
  return unless organization
  return unless organization.areas.where(name:, area_type:).where.not(id:).any?

  errors.add(:name, :taken)
end