Class: Notee::CategoriesController
Instance Method Summary
collapse
#restrict_access_json, #set_request_filter
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/notee/categories_controller.rb', line 17
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
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/notee/categories_controller.rb', line 38
def destroy
Category.transaction do
respond_to do |format|
if @category.update(slug: nil, is_deleted: true)
format.json { render json: @category, status: 200 }
else
format.json { render json: @category.errors, status: :unprocessable_entity }
end
end
end
end
|
#index ⇒ Object
8
9
10
11
|
# File 'app/controllers/notee/categories_controller.rb', line 8
def index
@categories = Category.where(is_deleted: false)
render json: { status: 'success', categories: @categories }
end
|
#restrict_parent_ids ⇒ Object
50
51
52
53
|
# File 'app/controllers/notee/categories_controller.rb', line 50
def restrict_parent_ids
@ids = Category.new.restrict_parent_ids(params[:id])
render json: { status: 'success', ids: @ids }
end
|
#show ⇒ Object
13
14
15
|
# File 'app/controllers/notee/categories_controller.rb', line 13
def show
render json: { status: 'success', category: @category }
end
|
#update ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/notee/categories_controller.rb', line 28
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
|