aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-10-26 09:29:38 +0200
committerJosé Valim <jose.valim@gmail.com>2011-10-26 09:29:38 +0200
commitaef62c4b4e89e7fa91973c188c9e7f281a44ecd0 (patch)
treea95ad005538d00d71ee0df0de9977d2fac7aeda6
parent20c59dd214b771efd978c7b35b314a785ffc176a (diff)
downloadrails-aef62c4b4e89e7fa91973c188c9e7f281a44ecd0.tar.gz
rails-aef62c4b4e89e7fa91973c188c9e7f281a44ecd0.tar.bz2
rails-aef62c4b4e89e7fa91973c188c9e7f281a44ecd0.zip
Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box.
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb4
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