aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-12-29 22:28:30 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-12-29 22:28:30 +0000
commit54e56ddb6050257966cadbbd5d4d0c9b10f17f8e (patch)
tree60e131d4e6f31d6cd2573194c98654dd09d0771d
parent73101af6ab89034b53e86c28b2f8a9f14eece950 (diff)
downloadrails-54e56ddb6050257966cadbbd5d4d0c9b10f17f8e.tar.gz
rails-54e56ddb6050257966cadbbd5d4d0c9b10f17f8e.tar.bz2
rails-54e56ddb6050257966cadbbd5d4d0c9b10f17f8e.zip
Validating save returns boolean; update and create return responses.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5810 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activeresource/lib/active_resource/base.rb7
-rw-r--r--activeresource/lib/active_resource/validations.rb5
2 files changed, 6 insertions, 6 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index b5ebd3961c..7f99e5cbf5 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -205,13 +205,12 @@ module ActiveResource
def update
connection.put(element_path, to_xml)
- true
end
def create
- resp = connection.post(collection_path, to_xml)
- self.id = id_from_response(resp)
- true
+ returning connection.post(collection_path, to_xml) do |response|
+ self.id = id_from_response(response)
+ end
end
# takes a response from a typical create post and pulls the ID out
diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb
index 3011ba3295..c45655d1ea 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -109,9 +109,10 @@ module ActiveResource
def save_with_validation
save_without_validation
+ true
rescue ResourceInvalid => error
errors.from_xml(error.response.body)
- return false
+ false
end
def valid?
@@ -123,4 +124,4 @@ module ActiveResource
@errors ||= Errors.new(self)
end
end
-end \ No newline at end of file
+end