module Undercarriage::Controllers::Restful::LocationAfterConcern
Location after
Redirect locations after create, update or destroy
Usage
class ExamplesController < ApplicationController include Undercarriage::Controllers::Restful::LocationAfterConcern end
Protected Instance Methods
location_after_create()
click to toggle source
Location after create
The path of the created resource
# File lib/undercarriage/controllers/restful/location_after_concern.rb, line 28 def location_after_create resource_id = @create_resource resource_path(resource_id) end
location_after_destroy()
click to toggle source
Location after destroy
The path of the resources
# File lib/undercarriage/controllers/restful/location_after_concern.rb, line 50 def location_after_destroy location_after_save end
location_after_save()
click to toggle source
Location after save
The path of the resources
# File lib/undercarriage/controllers/restful/location_after_concern.rb, line 59 def location_after_save resources_path end
location_after_update()
click to toggle source
Location after update
The path of the updated resource
# File lib/undercarriage/controllers/restful/location_after_concern.rb, line 39 def location_after_update resource_id = @update_resource resource_path(resource_id) end
Private Instance Methods
resource_path(resource, options = {})
click to toggle source
# File lib/undercarriage/controllers/restful/location_after_concern.rb, line 65 def resource_path(resource, options = {}) location_path = [resource_namespace, controller_name_singular].compact send("#{location_path.join('_')}_path", resource, options) end
resources_path(options = {})
click to toggle source
# File lib/undercarriage/controllers/restful/location_after_concern.rb, line 71 def resources_path(options = {}) location_path = [resource_namespace, controller_name].compact.map(&:to_sym) polymorphic_path(location_path, options) end