Class: Notee::CommentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Notee::CommentsController
- Defined in:
- app/controllers/notee/comments_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/controllers/notee/comments_controller.rb', line 17 def create @comment = Comment.new(comment_params) if @comment.save render json: { status: 'success' } else render json: { status: 'failed' } end end |
#destroy ⇒ Object
36 37 38 39 |
# File 'app/controllers/notee/comments_controller.rb', line 36 def destroy @comment.destroy render json: { status: 'success' } end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/notee/comments_controller.rb', line 7 def index comments = Comment.all.order(updated_at: :desc) render json: { status: 'success', comments: comments } end |
#show ⇒ Object
12 13 14 15 |
# File 'app/controllers/notee/comments_controller.rb', line 12 def show @comments = Comment.where(post_id: params[:id]) render json: { status: 'success', comments: @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 @comment.update(post_params) format.json { render json: @comment, status: 200 } else format.json { render json: @comment.errors, status: :unprocessable_entity } end end end |