Module: GardenVariety::UpdateAction

Defined in:
lib/garden_variety/actions.rb

Instance Method Summary collapse

Instance Method Details

#updatevoid #update { ... } ⇒ void

This method returns an undefined value.

Garden variety controller update action.

Overloads:

  • #update { ... } ⇒ void

    Yields:

    • on-success callback, replaces default redirect



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/garden_variety/actions.rb', line 64

def update
  self.model = (model = assign_attributes(authorize(find_model)))
  if model.save
    flash[:success] = flash_message(:success)
    block_given? ? yield : redirect_to(model)
    flash.discard(:success) if REDIRECT_CODES.exclude?(response.status)
  else
    flash.now[:error] = flash_message(:error)
    render :edit
  end
end