Class: Oxidizer::NestedResourceController

Inherits:
NestedResourcesController show all
Defined in:
app/controllers/oxidizer/nested_resource_controller.rb

Overview

Controller for nesting a singular resource within a parent resource. This should only be used for creating a new resource within the scope of the parent resource, or to redirect to the un-nested resource location if it exists.

Instance Method Summary collapse

Methods inherited from ResourcesController

#create, #destroy, #edit, #index, #new, resource, #update

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/oxidizer/nested_resource_controller.rb', line 6

def show
  # Disabled for show because show will only redirect to either
  # the new resource or to the existing resource, which both have
  # authorizations of their own. I did this here and not as a `skip_after_filter`
  # to add safety for a future engineer who might try to incorrectly override
  # this action and render the resource. If that happened, authorization would
  # be disabled for them, which wouldn't be great.
  skip_authorization
  redirect_to resource.present? ? existing_resource_url : new_resource_url
end