I am testing the following method:
def destroy
if @article.destroy
render json nothing: true, message: "removed", status: :ok
else
render json: @article, message: "Failed to remove", status: :bad_request
end
end
The line render json nothinggenerates an error
undefined `json 'method for #Api :: V1 :: ArticlesController: 0x000000074f6148
Changing the string to render json: message: "removed", status: :okdoes not matter. How to do nothing?
Update: I tried the code below, which, after uninstalling, responds No response receivedwhile I am expecting a message.
def destroy
if @article.destroy
respond_to do |format|
format.json { render nothing: true, message: "removed", status: :ok }
end
else
render json: @article, message: "Failed to remove", status: :bad_request
end
end
Marty source
share