aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-09-20 19:31:17 +0000
committerRick Olson <technoweenie@gmail.com>2006-09-20 19:31:17 +0000
commit4d63e01fa052749f742e90bcb3889cbae6152c92 (patch)
tree5f6b63d7b74685ff80a2366b4f3d0d6124176a09 /activeresource/lib
parent5e5b87b412e310fac4980fa5dc0ed7f0e58771cd (diff)
downloadrails-4d63e01fa052749f742e90bcb3889cbae6152c92.tar.gz
rails-4d63e01fa052749f742e90bcb3889cbae6152c92.tar.bz2
rails-4d63e01fa052749f742e90bcb3889cbae6152c92.zip
fixed failing tests now that non-GET requests are sent with .xml file ext. Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5153 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib')
-rw-r--r--activeresource/lib/active_resource/base.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 89724b1814..647fd90bb5 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -164,10 +164,15 @@ module ActiveResource
def create
returning connection.post(self.class.collection_path(prefix_options), to_xml) do |resp|
- self.id = resp['Location'][/\/([^\/]*?)(\.\w+)?$/, 1]
+ self.id = id_from_response(resp)
end
end
+ # takes a response from a typical create post and pulls the ID out
+ def id_from_response(response)
+ response['Location'][/\/([^\/]*?)(\.\w+)?$/, 1]
+ end
+
private
def find_or_create_resource_for_collection(name)
find_or_create_resource_for(name.to_s.singularize)