Class: Integral::Backend::CategoriesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Integral::Backend::CategoriesController
- Defined in:
- app/controllers/integral/backend/categories_controller.rb
Overview
Categories controller
Instance Method Summary collapse
-
#create ⇒ Object
POST / Category creation.
-
#edit ⇒ Object
GET /:id/edit Category update screen.
-
#update ⇒ Object
PUT /:id Updating a resource.
Methods inherited from BaseController
#activities, #activity, #destroy, #duplicate, #index, #list, #new, #show
Instance Method Details
#create ⇒ Object
POST / Category creation
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/integral/backend/categories_controller.rb', line 27 def create @resource = Integral::Category.new(resource_params) if @resource.save flash.now[:notice] = ('creation_success') render json: { redirect_url: request.referrer }, status: :created else render json: { message: ('creation_failure') }, status: :unprocessable_entity end end |
#edit ⇒ Object
GET /:id/edit Category update screen
21 22 23 |
# File 'app/controllers/integral/backend/categories_controller.rb', line 21 def edit render json: { content: render_to_string(partial: 'integral/backend/categories/modal', locals: { category: @resource, title: 'Edit Category', modal_id: "modal--category-edit-#{@resource.id}" }) } end |
#update ⇒ Object
PUT /:id Updating a resource
10 11 12 13 14 15 16 17 |
# File 'app/controllers/integral/backend/categories_controller.rb', line 10 def update if @resource.update(resource_params) flash.now[:notice] = ('edit_success') render json: { redirect_url: request.referrer }, status: :created else render json: { message: ('edit_failure') }, status: :unprocessable_entity end end |