aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/responder.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-10-14 10:25:43 +0100
committerJon Leighton <j@jonathanleighton.com>2010-10-14 10:25:43 +0100
commit3fb493c2b037ffbdda5c91d66334ec6f79faa2d1 (patch)
treee49b072103bbfe6fb6159954c786a31f44099325 /actionpack/lib/action_controller/metal/responder.rb
parent212fdd8ba9624f61421a7a950283537a3d39ac18 (diff)
parent01ab6f961bff150d50c99f03fa3946f48ac29b17 (diff)
downloadrails-3fb493c2b037ffbdda5c91d66334ec6f79faa2d1.tar.gz
rails-3fb493c2b037ffbdda5c91d66334ec6f79faa2d1.tar.bz2
rails-3fb493c2b037ffbdda5c91d66334ec6f79faa2d1.zip
Merge branch 'master' into nested_has_many_through
Conflicts: activerecord/lib/active_record/associations.rb activerecord/test/cases/associations/cascaded_eager_loading_test.rb
Diffstat (limited to 'actionpack/lib/action_controller/metal/responder.rb')
-rw-r--r--actionpack/lib/action_controller/metal/responder.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb
index 851925e1b7..38d32211cc 100644
--- a/actionpack/lib/action_controller/metal/responder.rb
+++ b/actionpack/lib/action_controller/metal/responder.rb
@@ -161,6 +161,8 @@ module ActionController #:nodoc:
display resource.errors, :status => :unprocessable_entity
elsif post?
display resource, :status => :created, :location => api_location
+ elsif has_empty_resource_definition?
+ display empty_resource, :status => :ok
else
head :ok
end
@@ -221,5 +223,23 @@ module ActionController #:nodoc:
def default_action
@action ||= ACTIONS_FOR_VERBS[request.request_method_symbol]
end
+
+ # Check whether resource needs a specific definition of empty resource to be valid
+ #
+ def has_empty_resource_definition?
+ respond_to?("empty_#{format}_resource")
+ end
+
+ # Delegate to proper empty resource method
+ #
+ def empty_resource
+ send("empty_#{format}_resource")
+ end
+
+ # Return a valid empty JSON resource
+ #
+ def empty_json_resource
+ "{}"
+ end
end
end