-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Delegate some additional methods in querying.rb #24315
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @pixeltrix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@kenta-s I agree that we should delegate https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation.rb#L279-L288 Can you modify the PR to just have the delegation, the tests and can you also add a CHANGELOG entry - thanks! |
In this case |
Thank you for your feedback! I will modify this PR to just have the delegation soon. and I will also check |
07807c9
to
04d1caf
Compare
@pixeltrix Done. And I also added |
assert !Topic.one? | ||
Topic.delete_all | ||
assert !Topic.one? | ||
Topic.new.save |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be Topic.create!
04d1caf
to
691242d
Compare
@pixeltrix Done! |
@@ -1,3 +1,7 @@ | |||
* Delegate `empty?`, `none?` and `one?`. Now they can be invoked as model class methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example for each case would be good here.
Topic.empty? # => false
Topic.one? # => true
Topic.none? # => false
691242d
to
78ea4c5
Compare
Updated. @vipulnsward Thank you for your feedback! :) |
@kenta-s thanks for your contribution 👍 |
I have seen many people write code like below so far.
if they can code like this,
the code will look more like RoR.
They can use
exists?
method of course. But I think there should beempty?
method as well.