aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-17 14:22:27 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-17 14:22:34 +0100
commitc0d31ca41b2f019d3bf940ac79f104c412b115bf (patch)
tree4946099ab3a6cdffbb82a3fd78e77a7f4dccef58 /activeresource/lib/active_resource
parent020e656447a7cc2ce9cbf83483ab3b31730a565e (diff)
downloadrails-c0d31ca41b2f019d3bf940ac79f104c412b115bf.tar.gz
rails-c0d31ca41b2f019d3bf940ac79f104c412b115bf.tar.bz2
rails-c0d31ca41b2f019d3bf940ac79f104c412b115bf.zip
save(false) is gone, use save(:validate => false) instead.
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r--activeresource/lib/active_resource/validations.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb
index 67b69fa505..7b2382bd8c 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -58,9 +58,8 @@ module ActiveResource
# person.save # => true (and person is now saved to the remote service)
#
module Validations
- extend ActiveSupport::Concern
+ extend ActiveSupport::Concern
include ActiveModel::Validations
- extend ActiveModel::Validations::ClassMethods
included do
alias_method_chain :save, :validation
@@ -68,7 +67,17 @@ module ActiveResource
# Validate a resource and save (POST) it to the remote web service.
# If any local validations fail - the save (POST) will not be attempted.
- def save_with_validation(perform_validation = true)
+ def save_with_validation(options=nil)
+ perform_validation = case options
+ when Hash
+ options[:validate] != false
+ when NilClass
+ true
+ else
+ ActiveSupport::Deprecation.warn "save(#{options}) is deprecated, please give save(:validate => #{options}) instead", caller
+ options
+ end
+
# clear the remote validations so they don't interfere with the local
# ones. Otherwise we get an endless loop and can never change the
# fields so as to make the resource valid