diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-04-24 16:16:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-24 16:16:00 -0400 |
commit | d4d145a6795ee7f461ef86a07e73a1f13fdb8574 (patch) | |
tree | ed4780a32c4e78d9890db43e02499e1b2e25d907 /activerecord/test/models | |
parent | 9834be65655e8552d25633b7376ab0654a23875d (diff) | |
parent | 5e24c333505c3bab3c85d834ac985281f141709f (diff) | |
download | rails-d4d145a6795ee7f461ef86a07e73a1f13fdb8574.tar.gz rails-d4d145a6795ee7f461ef86a07e73a1f13fdb8574.tar.bz2 rails-d4d145a6795ee7f461ef86a07e73a1f13fdb8574.zip |
Merge pull request #32313 from lulalala/model_error_as_object
Model error as object
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/reply.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index b35623a344..f6ab9c8a8f 100644 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -34,29 +34,29 @@ class WrongReply < Reply validate :check_author_name_is_secret, on: :special_case def check_empty_title - errors[:title] << "Empty" unless attribute_present?("title") + errors.add(:title, "Empty") unless attribute_present?("title") end def errors_on_empty_content - errors[:content] << "Empty" unless attribute_present?("content") + errors.add(:content, "Empty") unless attribute_present?("content") end def check_content_mismatch if attribute_present?("title") && attribute_present?("content") && content == "Mismatch" - errors[:title] << "is Content Mismatch" + errors.add(:title, "is Content Mismatch") end end def title_is_wrong_create - errors[:title] << "is Wrong Create" if attribute_present?("title") && title == "Wrong Create" + errors.add(:title, "is Wrong Create") if attribute_present?("title") && title == "Wrong Create" end def check_wrong_update - errors[:title] << "is Wrong Update" if attribute_present?("title") && title == "Wrong Update" + errors.add(:title, "is Wrong Update") if attribute_present?("title") && title == "Wrong Update" end def check_author_name_is_secret - errors[:author_name] << "Invalid" unless author_name == "secret" + errors.add(:author_name, "Invalid") unless author_name == "secret" end end |