diff options
Diffstat (limited to 'activeresource/lib')
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 7 |
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) |