diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-04-26 02:11:16 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-04-26 02:11:16 +0000 |
commit | 37e8e35c92222537ff82aa3c47cadebad4c32ce0 (patch) | |
tree | 968a1d77b11ea690827b0b8e06751e257c45ee1a /activeresource/lib/active_resource/base.rb | |
parent | 46b58d80b95232bff0435d9e5ab0a3281872005f (diff) | |
download | rails-37e8e35c92222537ff82aa3c47cadebad4c32ce0.tar.gz rails-37e8e35c92222537ff82aa3c47cadebad4c32ce0.tar.bz2 rails-37e8e35c92222537ff82aa3c47cadebad4c32ce0.zip |
Added load_attributes_from_response as a way of loading attributes from other responses than just create [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6586 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index be0560879d..4635a5009e 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -297,12 +297,15 @@ module ActiveResource def create returning connection.post(collection_path, to_xml) do |response| self.id = id_from_response(response) - - if response['Content-size'] != "0" && response.body.strip.size > 0 - load(connection.xml_from_response(response)) - end + load_attributes_from_response(response) end end + + def load_attributes_from_response(response) + if response['Content-size'] != "0" && response.body.strip.size > 0 + load(connection.xml_from_response(response)) + end + end # Takes a response from a typical create post and pulls the ID out def id_from_response(response) |