Fix response format handling when creating a comment
This commit is contained in:
@ -37,7 +37,6 @@ class CommentsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@comment = Comment.new(comment_params_without_request_id)
|
@comment = Comment.new(comment_params_without_request_id)
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @comment.save
|
if @comment.save
|
||||||
if comment_params[:request_id]
|
if comment_params[:request_id]
|
||||||
request_for_comment = RequestForComment.find(comment_params[:request_id])
|
request_for_comment = RequestForComment.find(comment_params[:request_id])
|
||||||
@ -49,19 +48,16 @@ class CommentsController < ApplicationController
|
|||||||
else
|
else
|
||||||
render json: @comment.errors, status: :unprocessable_entity
|
render json: @comment.errors, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
# PATCH/PUT /comments/1.json
|
# PATCH/PUT /comments/1.json
|
||||||
def update
|
def update
|
||||||
respond_to do |format|
|
|
||||||
if @comment.update(comment_params_without_request_id)
|
if @comment.update(comment_params_without_request_id)
|
||||||
render :show, status: :ok, location: @comment
|
render :show, status: :ok, location: @comment
|
||||||
else
|
else
|
||||||
render json: @comment.errors, status: :unprocessable_entity
|
render json: @comment.errors, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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'
|
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'
|
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
|
resources :subscriptions, only: [:create, :destroy] do
|
||||||
member do
|
member do
|
||||||
|
Reference in New Issue
Block a user