aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2006-10-02 22:14:15 +0000
committerJamis Buck <jamis@37signals.com>2006-10-02 22:14:15 +0000
commit628838ed9349252eccd86b531959c111e285893e (patch)
tree2a7960e22b381eddf691dacc96cd18925de64dc8 /activeresource/lib/active_resource
parent48d4d43f9236f705e2e81bc1781c8c37384886a9 (diff)
downloadrails-628838ed9349252eccd86b531959c111e285893e.tar.gz
rails-628838ed9349252eccd86b531959c111e285893e.tar.bz2
rails-628838ed9349252eccd86b531959c111e285893e.zip
Make #save behavior mimic AR::Base#save (true on success, false on failure)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5220 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r--activeresource/lib/active_resource/base.rb7
-rw-r--r--activeresource/lib/active_resource/validations.rb5
2 files changed, 7 insertions, 5 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index cb520eef5c..656698fb25 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -169,12 +169,13 @@ module ActiveResource
def update
connection.put(self.class.element_path(id, prefix_options), to_xml)
+ true
end
def create
- returning connection.post(self.class.collection_path(prefix_options), to_xml) do |resp|
- self.id = id_from_response(resp)
- end
+ resp = connection.post(self.class.collection_path(prefix_options), to_xml)
+ self.id = id_from_response(resp)
+ true
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 f1995a6070..3011ba3295 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -109,8 +109,9 @@ module ActiveResource
def save_with_validation
save_without_validation
- rescue ResourceInvalid
- errors.from_xml($!.response.body)
+ rescue ResourceInvalid => error
+ errors.from_xml(error.response.body)
+ return false
end
def valid?