From aef62c4b4e89e7fa91973c188c9e7f281a44ecd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 26 Oct 2011 09:29:38 +0200 Subject: Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box. --- railties/CHANGELOG | 2 ++ .../generators/rails/scaffold_controller/templates/controller.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 7f7b24804d..404bc73b0b 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *Rails 3.2.0 (unreleased)* +* Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box. [José Valim] + * Updated Rails::Rack::Logger middleware to apply any tags set in config.log_tags to the newly ActiveSupport::TaggedLogging Rails.logger. This makes it easy to tag log lines with debug information like subdomain and request id -- both very helpful in debugging multi-user production applications [DHH] * Default options to `rails new` can be set in ~/.railsrc [Guillermo Iguaran] diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb index 32b961d9fc..4ff15fd288 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -62,7 +62,7 @@ class <%= controller_class_name %>Controller < ApplicationController respond_to do |format| if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %> format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> } - format.json { head :ok } + format.json { head :no_content } else format.html { render <%= key_value :action, '"edit"' %> } format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> } @@ -78,7 +78,7 @@ class <%= controller_class_name %>Controller < ApplicationController respond_to do |format| format.html { redirect_to <%= index_helper %>_url } - format.json { head :ok } + format.json { head :no_content } end end end -- cgit v1.2.3