Module: Tramway::Core::ApplicationForms::SubmitHelper

Included in:
Tramway::Core::ApplicationForm
Defined in:
app/forms/tramway/core/application_forms/submit_helper.rb

Instance Method Summary collapse

Instance Method Details

#saveObject



16
17
18
19
20
21
22
23
# File 'app/forms/tramway/core/application_forms/submit_helper.rb', line 16

def save
  model.save
rescue ArgumentError => e
  Tramway::Error.raise_error :tramway, :core, :application_form, :save, :argument_error, message: e.message
rescue StandardError => e
  Tramway::Error.raise_error :tramway, :core, :application_form, :save, :looks_like_you_have_method,
    method_name: e.name.to_s.gsub('=', ''), model_class: @@model_class, class_name: self.class
end

#submit(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/forms/tramway/core/application_forms/submit_helper.rb', line 4

def submit(params)
  if params
    params.each { |key, value| send("#{key}=", value) }
    result = save
    result.tap do
      collecting_associations_errors unless result
    end
  else
    Tramway::Error.raise_error(:tramway, :core, :application_form, :submit, :params_should_not_be_nil)
  end
end