class Frigate::Operation::Action::Update

Is here to perform update action of operation

Public Instance Methods

action() click to toggle source

An update action is defined in here

# 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