Class: Decidim::ParticipatoryDocuments::CreateSuggestion
- Inherits:
-
Command
- Object
- Command
- Decidim::ParticipatoryDocuments::CreateSuggestion
- Includes:
- AttachmentMethods
- Defined in:
- app/commands/decidim/participatory_documents/create_suggestion.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, suggestable) ⇒ CreateSuggestion
constructor
A new instance of CreateSuggestion.
Constructor Details
#initialize(form, suggestable) ⇒ CreateSuggestion
Returns a new instance of CreateSuggestion.
8 9 10 11 |
# File 'app/commands/decidim/participatory_documents/create_suggestion.rb', line 8 def initialize(form, suggestable) @form = form @suggestable = suggestable end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/commands/decidim/participatory_documents/create_suggestion.rb', line 13 def call return broadcast(:invalid) if form.invalid? begin transaction do create_suggestion end broadcast(:ok, suggestion) rescue ActiveRecord::RecordInvalid => e Rails.logger.info e. broadcast(:invalid, e.) end end |