Class: Decidim::Proposals::Admin::ProposalForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Proposals::Admin::ProposalForm
- Defined in:
- app/forms/decidim/proposals/admin/proposal_form.rb
Overview
A form object to be used when admin users want to create a proposal.
Instance Method Summary collapse
-
#category ⇒ Object
Finds the Category from the category_id.
- #map_model(model) ⇒ Object
-
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
-
#scope_id ⇒ Object
Scope identifier.
Instance Method Details
#category ⇒ Object
Finds the Category from the category_id.
Returns a Decidim::Category
41 42 43 |
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 41 def category @category ||= categories.find_by(id: category_id) end |
#map_model(model) ⇒ Object
30 31 32 33 34 |
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 30 def map_model(model) return unless model.categorization self.category_id = model.categorization.decidim_category_id end |
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
Returns a Decidim::Scope
48 49 50 |
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 48 def scope @scope ||= @scope_id ? current_participatory_space.scopes.find_by(id: @scope_id) : current_participatory_space.scope end |
#scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the proposal
55 56 57 |
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 55 def scope_id @scope_id || scope&.id end |