Class: Super::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Super::ApplicationController
- Includes:
- InlineCallback
- Defined in:
- app/controllers/super/application_controller.rb
Overview
Provides a default implementation for each of the resourceful actions
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods included from InlineCallback
Instance Method Details
#create ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/super/application_controller.rb', line 43 def create @resource = controls.scope(action: action_inquirer).build(create_permitted_params) if @resource.save redirect_to polymorphic_path(Super.configuration.path_parts(@resource)) else render :new, status: :bad_request end end |
#destroy ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'app/controllers/super/application_controller.rb', line 75 def destroy @resource = controls.scope(action: action_inquirer).find(params[:id]) if @resource.destroy redirect_to polymorphic_path(Super.configuration.path_parts(controls.model)) else redirect_to polymorphic_path(Super.configuration.path_parts(@resource)) end end |
#edit ⇒ Object
57 58 59 |
# File 'app/controllers/super/application_controller.rb', line 57 def edit @resource = controls.scope(action: action_inquirer).find(params[:id]) end |
#index ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/super/application_controller.rb', line 37 def index with_inline_callbacks do @resources = controls.scope(action: action_inquirer) end end |
#new ⇒ Object
53 54 55 |
# File 'app/controllers/super/application_controller.rb', line 53 def new @resource = controls.scope(action: action_inquirer).build end |
#show ⇒ Object
61 62 63 |
# File 'app/controllers/super/application_controller.rb', line 61 def show @resource = controls.scope(action: action_inquirer).find(params[:id]) end |
#update ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/super/application_controller.rb', line 65 def update @resource = controls.scope(action: action_inquirer).find(params[:id]) if @resource.update(update_permitted_params) redirect_to polymorphic_path(Super.configuration.path_parts(@resource)) else render :edit, status: :bad_request end end |