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
Attribute query method documentation is misleading #16246
Comments
I always think if an attribute is numeric and has the default value, it should return whether the current value equals the default value, rather than zero, but at the same time I feel not many people may use these methods.... |
@asterite updated the docs accordingly. This behavior goes waaaay back (db045db, https://github.com/rails/rails/blob/db045db/activerecord/lib/active_record/base.rb#L903-L904) and will need a good reason to change. If you want to get more opinions about that, please use the rails-core mailing list to suggest that change. Thank you for reporting 💛 |
In fact we already have the discussion about this same thing on the Rails
|
@senny thanks! @rafaelfranca do you have a link to that discussion? I opened this issue because we had a bug in our app because of this strange behaviour and I'd like to understand better why it is like that. |
No, sorry. Try to search at the Rails Core google groups. |
According to the documentation, "Query methods allow you to test whether an attribute value is present". However:
This is very confusing. The documentation should be updated to show that for numeric values zero will return false. And it shouldn't include the word
present
, as people would associate it with thepresent?
method. And it should probably explain why there is a different behaviour for numerics (I don't know why).The text was updated successfully, but these errors were encountered: