Class: Frigate::Operation::Action::Update
- Defined in:
- lib/frigate/operation/action/update.rb
Overview
Is here to perform update action of operation
Instance Attribute Summary
Attributes inherited from Base
#action_result, #model, #model_form, #operation, #opts, #params
Instance Method Summary collapse
-
#action ⇒ Object
An update action is defined in here.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Frigate::Operation::Action::Base
Instance Method Details
#action ⇒ Object
An update action is defined in here
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/frigate/operation/action/update.rb', line 7 def action @model = model_klass.find_by_id(params[:id]) # TODO: add id verification @model_form = create_form(model) if model_form.validate(params) if operation_block operation_block(model, params) else model_form.sync_with_model(save: true) end else exception = InvalidParamsError.new('invalid params in %s' % operation.class.name) raise (exception.tap { |e| e.errors = model_form.errors }) end end |