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
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/notee/categories_controller.rb', line 18 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
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/notee/categories_controller.rb', line 39 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 |
#show ⇒ Object
13 14 15 16 |
# File 'app/controllers/notee/categories_controller.rb', line 13 def show p @category render json: { status: 'success', category: @category} end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/notee/categories_controller.rb', line 29 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 |