From 72d0784611af76dd0bb3154a662c6ec14a022f4c Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 15 May 2015 11:28:52 -0300 Subject: Make Rails API apps return the full resource on update --- .../generators/rails/scaffold_controller/templates/api_controller.rb | 2 +- .../generators/test_unit/scaffold/templates/api_functional_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb index ca76da6530..695b7cc90b 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb @@ -32,7 +32,7 @@ class <%= controller_class_name %>Controller < ApplicationController # PATCH/PUT <%= route_url %>/1 def update if @<%= orm_instance.update("#{singular_table_name}_params") %> - head :no_content + render json: <%= "@#{singular_table_name}" %> else render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity end diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb index 423437bba1..7e41162d47 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb @@ -27,7 +27,7 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase test "should update <%= singular_table_name %>" do patch :update, params: { id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> } - assert_response 204 + assert_response 200 end test "should destroy <%= singular_table_name %>" do -- cgit v1.2.3