Class: Notee::CommentsController
Instance Method Summary
collapse
#restrict_access_json, #set_request_filter
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/controllers/notee/comments_controller.rb', line 17
def create
= .new()
if .save
render json: { status: 'success' }
else
render json: { status: 'failed' }
end
end
|
#destroy ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/notee/comments_controller.rb', line 36
def destroy
respond_to do |format|
if .update(is_deleted: true)
format.json { render json: , status: 200 }
else
format.json { render json: .errors, status: :internal_server_error }
end
end
end
|
#index ⇒ Object
7
8
9
10
|
# File 'app/controllers/notee/comments_controller.rb', line 7
def index
= .where(is_deleted: false).order(updated_at: :desc)
render json: { status: 'success', comments: }
end
|
#show ⇒ Object
12
13
14
15
|
# File 'app/controllers/notee/comments_controller.rb', line 12
def show
= .where(post_id: params[:id])
render json: { status: 'success', comments: }
end
|
#update ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/notee/comments_controller.rb', line 26
def update
respond_to do |format|
if .update(is_hidden: !.is_hidden)
format.json { render json: , status: 200 }
else
format.json { render json: .errors, status: :unprocessable_entity }
end
end
end
|