Class: Notee::CategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Notee::CategoriesController
- Defined in:
- app/controllers/notee/categories_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/notee/categories_controller.rb', line 13 def create @category = Category.new(category_params) respond_to do |format| if @category.save format.json { render json: @category, status: 200 } else format.json { render json: @category.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/notee/categories_controller.rb', line 34 def destroy respond_to do |format| if @category.destroy format.json { render json: @category, status: 200 } else format.json { render json: @category.errors, status: :internal_server_error } end end end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/notee/categories_controller.rb', line 8 def index @categories = Category.all render json: { status: 'success', categories: @categories} end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/notee/categories_controller.rb', line 24 def update respond_to do |format| if @category.update(category_params) format.json { render json: @category, status: 200 } else format.json { render json: @category.errors, status: :unprocessable_entity } end end end |