diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-03-19 23:28:59 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-19 23:28:59 +0000 |
commit | 8828b2ca674acfa028a3c1e086a1795d3bb893e1 (patch) | |
tree | 17a0b5793d99e0c0a05f31c70adea642946a87a3 /activemodel/lib/active_model/deprecated_error_methods.rb | |
parent | 6ed42ebdff05f9d28a60e91093d8f9afad03a958 (diff) | |
download | rails-8828b2ca674acfa028a3c1e086a1795d3bb893e1.tar.gz rails-8828b2ca674acfa028a3c1e086a1795d3bb893e1.tar.bz2 rails-8828b2ca674acfa028a3c1e086a1795d3bb893e1.zip |
Move all the Active Record validations to Active Model
Diffstat (limited to 'activemodel/lib/active_model/deprecated_error_methods.rb')
-rw-r--r-- | activemodel/lib/active_model/deprecated_error_methods.rb | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/activemodel/lib/active_model/deprecated_error_methods.rb b/activemodel/lib/active_model/deprecated_error_methods.rb index e0cbd9ba29..b0d7023046 100644 --- a/activemodel/lib/active_model/deprecated_error_methods.rb +++ b/activemodel/lib/active_model/deprecated_error_methods.rb @@ -1,37 +1,28 @@ module ActiveModel module DeprecatedErrorMethods def on(attribute) - ActiveSupport::Deprecation.warn "Errors#on have been deprecated, use Errors#[] instead" - self[attribute] + # ActiveSupport::Deprecation.warn "Errors#on have been deprecated, use Errors#[] instead" + errors = self[attribute] + errors.size < 2 ? errors.first : errors end def on_base - ActiveSupport::Deprecation.warn "Errors#on_base have been deprecated, use Errors#[:base] instead" + # ActiveSupport::Deprecation.warn "Errors#on_base have been deprecated, use Errors#[:base] instead" on(:base) end - def add(attribute, msg = Errors.default_error_messages[:invalid]) - ActiveSupport::Deprecation.warn "Errors#add(attribute, msg) has been deprecated, use Errors#[attribute] << msg instead" - self[attribute] << msg - end - def add_to_base(msg) - ActiveSupport::Deprecation.warn "Errors#add_to_base(msg) has been deprecated, use Errors#[:base] << msg instead" + # ActiveSupport::Deprecation.warn "Errors#add_to_base(msg) has been deprecated, use Errors#[:base] << msg instead" self[:base] << msg end def invalid?(attribute) - ActiveSupport::Deprecation.warn "Errors#invalid?(attribute) has been deprecated, use Errors#[attribute].any? instead" + # ActiveSupport::Deprecation.warn "Errors#invalid?(attribute) has been deprecated, use Errors#[attribute].any? instead" self[attribute].any? end - def full_messages - ActiveSupport::Deprecation.warn "Errors#full_messages has been deprecated, use Errors#to_a instead" - to_a - end - def each_full - ActiveSupport::Deprecation.warn "Errors#each_full has been deprecated, use Errors#to_a.each instead" + # ActiveSupport::Deprecation.warn "Errors#each_full has been deprecated, use Errors#to_a.each instead" to_a.each { |error| yield error } end end |