Deprecate ActiveModel::Errors get, set and []= methods.#18634
Deprecate ActiveModel::Errors get, set and []= methods.#18634rafaelfranca merged 1 commit intorails:masterfrom
ActiveModel::Errors get, set and []= methods.#18634Conversation
65043c5 to
cddd4ea
Compare
|
In complex service objects, we use |
There was a problem hiding this comment.
Does it need to call delete?
There was a problem hiding this comment.
It doesn't need to - already fixed.
cddd4ea to
4d4f8c9
Compare
|
@egilburg I can see that |
|
Huh? I thought add on empty means add error if model doesn't have already error with that key. Eugene
|
|
@egilburg Nope, it adds u = User.new
u.errors.add(:email, :invalid)
u.errors.add_on_empty(:email)
# => [:email]
u.errors.full_messages
# => ["Email is invalid", "Email can't be empty"]It also adds this error when value is |
|
@egilburg Did I understand you correctly, that you misused |
|
@morgoth yes it doesn't seem to be what I thought it is. |
|
@rafaelfranca this PR is good to go. WDYT about deprecating |
They have inconsistent behaviour currently.
4d4f8c9 to
6ec8ba1
Compare
|
Yeah, let deprecated those methods too. |
Deprecate `ActiveModel::Errors` `get`, `set` and `[]=` methods.
|
For people coming here from This week in Rails, see f55bfe7. Summary:
|
They have inconsistent behaviour currently.
As discussed in #18631
Do you think we can go further and deprecate also
add_on_blankandadd_on_empty?Not sure what is the usecase for them and it's easy enough to write it on your own when needed.