Class: Decidim::Elections::Admin::AnswerForm
- Inherits:
-
Form
- Object
- AttributeObject::Form
- Form
- Decidim::Elections::Admin::AnswerForm
- Includes:
- AttachmentAttributes, TranslatableAttributes
- Defined in:
- decidim-elections/app/forms/decidim/elections/admin/answer_form.rb
Overview
This class holds a Form to create/update answers from Decidim’s admin panel.
Constant Summary
Constants included from AttributeObject::TypeMap
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary
Attributes inherited from AttributeObject::Form
Instance Method Summary collapse
Methods included from TranslatableAttributes
Methods inherited from AttributeObject::Form
ensure_hash, from_model, from_params, hash_from, infer_model_name, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context
Methods included from AttributeObject::Model
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#election ⇒ Object
33 34 35 |
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 33 def election @election ||= context[:election] end |
#map_model(model) ⇒ Object
22 23 24 |
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 22 def map_model(model) self.proposal_ids = model.linked_resources(:proposals, "related_proposals").pluck(:id) end |
#proposals ⇒ Object
26 27 28 29 30 31 |
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 26 def proposals @proposals ||= Decidim.find_resource_manifest(:proposals) .try(:resource_scope, current_component) &.where(id: proposal_ids) &.order(title: :asc) end |
#question ⇒ Object
37 38 39 |
# File 'decidim-elections/app/forms/decidim/elections/admin/answer_form.rb', line 37 def question @question ||= context[:question] end |