Skip to content

Commit

Permalink
Merge pull request #143 from claudiob/respond-to-json-PUT-with-ok-and…
Browse files Browse the repository at this point in the history
…-content

Respond to PUT/PATCH API request with :ok
  • Loading branch information
rwz committed Oct 24, 2013
2 parents b1ec3c4 + 9dbce9c commit 6b1b531
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/generators/rails/templates/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def update
respond_to do |format|
if @<%= orm_instance.update("#{singular_table_name}_params") %>
format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> }
format.json { head :no_content }
format.json { render action: 'show', status: :ok, location: <%= "@#{singular_table_name}" %> }
else
format.html { render action: 'edit' }
format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity }
Expand Down
2 changes: 1 addition & 1 deletion test/scaffold_controller_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase

assert_instance_method :update, content do |m|
assert_match /format\.html \{ redirect_to @post, notice: 'Post was successfully updated\.' \}/, m
assert_match /format\.json \{ head :no_content \}/, m
assert_match /format\.json \{ render action: 'show', status: :ok, location: @post \}/, m
assert_match /format\.html \{ render action: 'edit' \}/, m
assert_match /format\.json \{ render json: @post.errors, status: :unprocessable_entity \}/, m
end
Expand Down

0 comments on commit 6b1b531

Please sign in to comment.