Module: Undercarriage::Controllers::Restful::Actions::DestroyConcern

Extended by:
ActiveSupport::Concern
Defined in:
lib/undercarriage/controllers/restful/actions/destroy_concern.rb

Overview

Destroy restful action

Examples:

Controller

class ExamplesController < ApplicationController
  include Undercarriage::Controllers::Restful::Actions::DestroyConcern
end

Instance Method Summary collapse

Instance Method Details

#destroyObject

Destroy action

Examples:

Controller

class ExamplesController < ApplicationController
  include Undercarriage::Controllers::RestfulConcern

  ##
  # This method is only needed if you want to override the action entirely. Otherwise, it is not needed.
  # Database resources can be accessed as `@destroy_resource` or `@example`
  #
  # def destroy
  #   ...
  # end
end


41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/undercarriage/controllers/restful/actions/destroy_concern.rb', line 41

def destroy
  @destroy_resource.destroy

  respond_to do |format|
    format.html do
      flash[flash_status_type] = flash_destroyed_message

      redirect_to location_after_destroy
    end
    format.json { head :no_content }
  end
end