From c0d31ca41b2f019d3bf940ac79f104c412b115bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 17 Jan 2010 14:22:27 +0100 Subject: save(false) is gone, use save(:validate => false) instead. --- activeresource/lib/active_resource/validations.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'activeresource/lib/active_resource') 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 -- cgit v1.2.3