Module: GardenVariety::DestroyAction

Defined in:
lib/garden_variety/actions.rb

Instance Method Summary collapse

Instance Method Details

#destroyvoid #destroy { ... } ⇒ void

This method returns an undefined value.

Garden variety controller destroy action.

Overloads:

  • #destroy { ... } ⇒ void

    Yields:

    • on-success callback, replaces default redirect



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/garden_variety/actions.rb', line 83

def destroy
  self.model = (model = authorize(find_model))
  if model.destroy
    flash[:success] = flash_message(:success)
    block_given? ? yield : redirect_to(action: :index)
    flash.discard(:success) if REDIRECT_CODES.exclude?(response.status)
  else
    flash.now[:error] = flash_message(:error)
    render :show
  end
end