Module: Undercarriage::Controllers::Restful::Actions::CreateConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/undercarriage/controllers/restful/actions/create_concern.rb
Overview
Create restful action
Usage
class ExamplesController < ApplicationController
include Undercarriage::Controllers::RestfulConcern
end
Instance Method Summary collapse
-
#create ⇒ Object
Create action.
Instance Method Details
#create ⇒ Object
Create 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 `@create_resource` or `@example`
#
# def create
# ...
# end
end
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/undercarriage/controllers/restful/actions/create_concern.rb', line 41 def create nested_resource_pre_build respond_to do |format| if @create_resource.save after_create_action format.html do flash[flash_status_type] = redirect_to location_after_create end format.json { render :show, status: :created, location: location_after_create } else nested_resource_build format.html { render :new, status: :unprocessable_entity } format.json { render json: @create_resource.errors, status: :unprocessable_entity } end end end |