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

Has_many association with the i18n scope return wrong records. Key value backend. #23

Closed
iamdeuterium opened this issue Apr 18, 2017 · 6 comments

Comments

@iamdeuterium
Copy link

Example:

[53] ruby 2.4.1(main)> i = Dictionaries::Industry.find 2
[54] ruby 2.4.1(main)> i.categories
=> [#<Dictionaries::Category:0x007f44acaae4a0 id: 13, industry_id: 2, slug: "uplotnitelnaya-tehnika">,
 #<Dictionaries::Category:0x007f44acaaddc0 id: 16, industry_id: 2, slug: "dorozhnye-frezy">]
[55] ruby 2.4.1(main)> i.categories.i18n
=> [#<Dictionaries::Category:0x005560c2095a88 id: 13, industry_id: 2, slug: "uplotnitelnaya-tehnika">,
 #<Dictionaries::Category:0x005560c20952e0 id: 16, industry_id: 2, slug: "dorozhnye-frezy">]
[56] ruby 2.4.1(main)> 
[57] ruby 2.4.1(main)> 
[58] ruby 2.4.1(main)> i = Dictionaries::Industry.find 5
[59] ruby 2.4.1(main)> i.categories
=> [#<Dictionaries::Category:0x007f44ac7a5880 id: 36, industry_id: 5, slug: "cazhalki">,
 #<Dictionaries::Category:0x007f44ac7a56a0 id: 37, industry_id: 5, slug: "zhatki">,
 #<Dictionaries::Category:0x007f44ac79aea8 id: 55, industry_id: 5, slug: "uborochnaya-tehnika-dlya-sena-furazha">]
[60] ruby 2.4.1(main)> i.categories.i18n
=> [#<Dictionaries::Category:0x005560c2095a88 id: 13, industry_id: 2, slug: "uplotnitelnaya-tehnika">,
 #<Dictionaries::Category:0x005560c20952e0 id: 16, industry_id: 2, slug: "dorozhnye-frezy">]
[61] ruby 2.4.1(main)> 
@iamdeuterium iamdeuterium changed the title Has_many association with the i18n scope return wrong records Has_many association with the i18n scope return wrong records. Key value backend. Apr 18, 2017
@shioyama
Copy link
Owner

Thanks, I think I know what's going wrong here, it's independent of what backend you're using.

I've just created a branch called do_not_memoize_scope, could you try using that and see if the issue disappears? If so I can fix and release a new version.

gem 'mobility', github: 'shioyama/mobility', branch: 'do_not_memoize_scope'

@shioyama
Copy link
Owner

Some specs are failing on that branch, related to the where.not pattern, so it may not be a complete fix. But please try it.

I'll look deeper into this issue on the weekend (maybe earlier, but it may be tricky...)

@shioyama
Copy link
Owner

Ok specs are now passing, although I'm not sure I totally understand the issue yet. Please try that branch, if it fixes the problem for you I will try to write a spec that tests this issue and then we can release a new version with a fix.

Thanks for reporting!

@iamdeuterium
Copy link
Author

Now it works correctly. :)

@shioyama
Copy link
Owner

Great thanks. I'll have a new release out today with the fix.

@shioyama
Copy link
Owner

Released 0.1.13 with the fix. Let me know if you notice any other strange things like this one 😄

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

No branches or pull requests

2 participants