diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index ef2ee4db..fcddf876 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -37,30 +37,26 @@ class CommentsController < ApplicationController def create @comment = Comment.new(comment_params_without_request_id) - respond_to do |format| - if @comment.save - if comment_params[:request_id] - request_for_comment = RequestForComment.find(comment_params[:request_id]) - send_mail_to_author @comment, request_for_comment - send_mail_to_subscribers @comment, request_for_comment - end - - render :show, status: :created, location: @comment - else - render json: @comment.errors, status: :unprocessable_entity + if @comment.save + if comment_params[:request_id] + request_for_comment = RequestForComment.find(comment_params[:request_id]) + send_mail_to_author @comment, request_for_comment + send_mail_to_subscribers @comment, request_for_comment end + + render :show, status: :created, location: @comment + else + render json: @comment.errors, status: :unprocessable_entity end authorize! end # PATCH/PUT /comments/1.json def update - respond_to do |format| - if @comment.update(comment_params_without_request_id) - render :show, status: :ok, location: @comment - else - render json: @comment.errors, status: :unprocessable_entity - end + if @comment.update(comment_params_without_request_id) + render :show, status: :ok, location: @comment + else + render json: @comment.errors, status: :unprocessable_entity end authorize! end diff --git a/config/routes.rb b/config/routes.rb index 3e6dca68..2fcf7d6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,7 @@ Rails.application.routes.draw do get '/my_rfc_activity', as: 'my_rfc_activity', to: 'request_for_comments#get_rfcs_with_my_comments' delete '/comment_by_id', to: 'comments#destroy_by_id' - put '/comments', to: 'comments#update' + put '/comments', to: 'comments#update', defaults: { format: :json } resources :subscriptions, only: [:create, :destroy] do member do