Sha256: 45a625261f4e90a641af69c9a1a439ab8970884726097cd5712f265b36f21af7
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
require_dependency "notee/application_controller" module Notee class CategoriesController < ApplicationController before_action :set_category, only: [:show, :update, :destroy] def index @categories = Category.all render json: { status: 'success', categories: @categories} end def show p @category render json: { status: 'success', category: @category} end 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 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 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 private def category_params params.require(:category).permit(:name, :slug, :parent_id, :is_private) end def set_category @category = Category.find_by(id: params[:id]) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
notee-0.3.5 | app/controllers/notee/categories_controller.rb |
notee-0.3.4.1 | app/controllers/notee/categories_controller.rb |
notee-0.3.4 | app/controllers/notee/categories_controller.rb |