diff options
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 1 | ||||
-rw-r--r-- | activemodel/test/cases/errors_test.rb | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 98e16ea455..805d042cac 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -74,6 +74,7 @@ module ActiveModel self.i18n_customize_full_message = false attr_reader :errors + alias :objects :errors # Pass in the instance of the object that is using the errors object. # diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 58aa7ee147..048b8a92fb 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -159,14 +159,14 @@ class ErrorsTest < ActiveModel::TestCase assert_equal :name, error.attribute assert_equal :blank, error.type - assert_equal error, person.errors.first + assert_equal error, person.errors.objects.first end test "add, with type as symbol" do person = Person.new person.errors.add(:name, :blank) - assert_equal :blank, person.errors.first.type + assert_equal :blank, person.errors.objects.first.type assert_equal ["can't be blank"], person.errors[:name] end @@ -183,7 +183,7 @@ class ErrorsTest < ActiveModel::TestCase person = Person.new person.errors.add(:name) - assert_equal :invalid, person.errors.first.type + assert_equal :invalid, person.errors.objects.first.type assert_equal ["is invalid"], person.errors[:name] end @@ -203,7 +203,7 @@ class ErrorsTest < ActiveModel::TestCase person = Person.new person.errors.add(:name, type) - assert_equal :blank, person.errors.first.type + assert_equal :blank, person.errors.objects.first.type assert_equal ["can't be blank"], person.errors[:name] end @@ -214,7 +214,7 @@ class ErrorsTest < ActiveModel::TestCase person = Person.new person.errors.add(:name, :blank, message: type) - assert_equal :blank, person.errors.first.type + assert_equal :blank, person.errors.objects.first.type assert_equal [msg], person.errors[:name] end @@ -225,7 +225,7 @@ class ErrorsTest < ActiveModel::TestCase person = Person.new person.errors.add(:name, message: type) - assert_equal :invalid, person.errors.first.type + assert_equal :invalid, person.errors.objects.first.type assert_equal [msg], person.errors[:name] end |