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

Include query_scope in find_by methods #480

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shioyama
Copy link
Owner

@shioyama shioyama commented Dec 20, 2020

It makes sense to include the query scope automatically in the find_by methods (find_by_title etc) so they work out of the box.

Assume title is a translated attribute:

Before

Post.i18n.find_by_title('foo')
#=> <Post ...>
Post.find_by_title('foo')
#=> ActiveRecord::StatementInvalid ...

After

Post.i18n.find_by_title('foo')
#=> <Post ...>
Post.find_by_title('foo')
#=> <Post ...>

@shioyama shioyama force-pushed the include_query_method_in_find_by_methods branch 3 times, most recently from d955f12 to ab32ad8 Compare December 21, 2020 05:02
@shioyama shioyama force-pushed the include_query_method_in_find_by_methods branch from bda0cf1 to bac037a Compare December 30, 2020 01:27
@madhums
Copy link

madhums commented Feb 5, 2024

Would be nice to merge this! @shioyama

@thisIsLoading
Copy link

yes, please, i just stumbled upon this in my new app. its unintuitive with the i18n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants