Class: Decidim::Solutions::SolutionsForm

Inherits:
Form
  • Object
show all
Includes:
AttachmentAttributes, HasUploadValidations
Defined in:
app/forms/decidim/solutions/solutions_form.rb

Overview

A form object to be used when public users want to create a solution.

Instance Method Summary collapse

Instance Method Details

#authorObject



45
46
47
# File 'app/forms/decidim/solutions/solutions_form.rb', line 45

def author
  Decidim::User.find(author_id)
end

#challengeObject

Finds the Challenge from the given decidim_challenges_challenge_id

Returns a Decidim::Challenges::Challenge



41
42
43
# File 'app/forms/decidim/solutions/solutions_form.rb', line 41

def challenge
  @challenge ||= @problem.present? ? Decidim::Challenges::Challenge.find(@problem.challenge.id) : Decidim::Challenges::Challenge.find(@decidim_challenges_challenge_id)
end

#map_model(model) ⇒ Object



30
31
32
33
34
35
36
# File 'app/forms/decidim/solutions/solutions_form.rb', line 30

def map_model(model)
  self.title = translated_attribute(model.title)
  self.description = translated_attribute(model.description)

  self.documents = model.attachments
  nil unless model.categorization
end