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.
-
#destroy ⇒ Object
Override redirect path DELETE /:id.
-
#edit ⇒ Object
GET /:id/edit Category update screen.
-
#update ⇒ Object
PUT /:id Updating a resource.
Methods inherited from BaseController
#activities, #activity, #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[:notice] = ('creation_success') render json: { redirect_url: request.referrer }, status: :created else render json: { message: ('creation_failure') }, status: :unprocessable_entity end end |
#destroy ⇒ Object
Override redirect path DELETE /:id
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/integral/backend/categories_controller.rb', line 40 def destroy if @resource.destroy respond_to do |format| format.html { respond_successfully(('delete_success'), send("backend_posts_path")) } format.js { head :no_content } end else respond_to do |format| format.html do = @resource.errors..to_sentence flash[:error] = "#{('delete_failure')} - #{}" redirect_to send("backend_posts_path") end format.js { head :unprocessable_entity } end 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[:notice] = ('edit_success') render json: { redirect_url: request.referrer }, status: :created else render json: { message: ('edit_failure') }, status: :unprocessable_entity end end |