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

Allow passing locale to query methods #233

Merged
merged 1 commit into from
May 27, 2018
Merged

Allow passing locale to query methods #233

merged 1 commit into from
May 27, 2018

Conversation

shioyama
Copy link
Owner

Replaces #210, much simpler now.

@shioyama
Copy link
Owner Author

Here's what this does:

Post.i18n.where(title: "foo", locale: :ja)
#=> returns post with Japanese title "foo"

The interface here may be slightly confusing, since you pass the locale as an option to i18n when setting the locale for block queries:

Post.i18n(locale: :ja) { title.eq("foo") }
#=> returns post with Japanese title "foo"

but this locale keyword to i18n will be ignored when used with query methods:

Post.i18n(locale:ja).where(title: "foo")
#=> ignores locale and returns post with title "foo" in current locale

For the above case to work, we would have to store the locale in the chained relation, which I don't think I really want to do.

@shioyama shioyama merged commit 78de63d into master May 27, 2018
@shioyama shioyama deleted the query_with_locale branch May 27, 2018 08:06
@shioyama shioyama mentioned this pull request May 27, 2018
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.

1 participant