module Undercarriage::Controllers::Restful::Actions::DestroyConcern
Destroy restful action
Usage
class ExamplesController < ApplicationController include Undercarriage::Controllers::RestfulConcern end
Public Instance Methods
destroy()
click to toggle source
Destroy action
Usage
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
# 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
Protected Instance Methods
destroy_resource_content()
click to toggle source
Destroy restful action
Usage
class ExamplesController < ApplicationController include Undercarriage::Controllers::RestfulConcern ## # This method is only needed if you want to override the query entirely. Otherwise, it is not needed. # Database resources can be accessed as `@example` # # def destroy_resource_content # ... # end ## # To add authorization through something like Pundit, the following could be used # # def destroy_resource_content # super # # authorize @example # end ## # The `resource_content` method can also be overwritten. Be careful with this because the `show`, # `edit` and `update` actions will also use this method # # def resource_content # ... # end end
# File lib/undercarriage/controllers/restful/actions/destroy_concern.rb, line 89 def destroy_resource_content resource_content end
Private Instance Methods
destroy_resource()
click to toggle source
# File lib/undercarriage/controllers/restful/actions/destroy_concern.rb, line 95 def destroy_resource @destroy_resource ||= destroy_resource_content end