Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the ActiveModel:Errors#full_message method to the Error class: #36639

Merged
merged 2 commits into from
Jul 16, 2019

Conversation

Edouard-chin
Copy link
Member

Move the ActiveModel:Errors#full_message method to the Error class:

  • One regression introduced by the "AM errors as object" features is
    about the full_messages method.

    It's currently impossible to call that method if the base object
    passed in the constructor of AM::Errors doesn't respond to the
    errors method.
    That's because full_messages now makes a weird back and forth trip

    AM::Errors#full_messages -> AM::Error#full_message -> AM::Errors#full_message

    Since full_message (singular) isn't needed by AM::Errors, I moved
    it to the AM::Error (singular) class. This way we don't need to
    grab the AM::Errors object from the base.

cc/ @casperisfine @rafaelfranca

@rails-bot rails-bot bot added the activemodel label Jul 9, 2019
@Edouard-chin Edouard-chin force-pushed the ec-am-errors-fullmessages branch 3 times, most recently from 328cdf1 to e86149e Compare July 10, 2019 21:32
default: defaults,
attribute: attr_name,
message: message)
Error.full_message(attribute, message, @base)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass @base.class downstream because we only use that.

@Edouard-chin Edouard-chin force-pushed the ec-am-errors-fullmessages branch 2 times, most recently from 475c9f0 to dd97dce Compare July 16, 2019 11:35
- One regression introduced by the "AM errors as object" features is
  about the `full_messages` method.

  It's currently impossible to call that method if the `base` object
  passed in the constructor of `AM::Errors` doesn't respond to the
  `errors` method.
  That's because `full_messages` now makes a weird back and forth trip

  `AM::Errors#full_messages` -> `AM::Error#full_message` -> `AM::Errors#full_message`

  Since `full_message` (singular) isn't needed by AM::Errors, I moved
  it to the `AM::Error` (singular) class. This way we don't need to
  grab the `AM::Errors` object from the base.
- Since `ActiveModel::Error` can now be inherited by
  `ActiveModel::NestedError`, when the latter generates a
  `full_message`, the `i18n_customize_full_message` accessor set in
  the parent class is not set.

  This commit fixes that by using a `class_attribute` instead.
@Edouard-chin
Copy link
Member Author

Should be good to go

@rafaelfranca rafaelfranca merged commit fdd5894 into rails:master Jul 16, 2019
@Edouard-chin Edouard-chin deleted the ec-am-errors-fullmessages branch July 16, 2019 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants