-
Notifications
You must be signed in to change notification settings - Fork 140
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
Fixes #432 - Create association on locale change #433
Conversation
a8ee2b4
to
06d45b1
Compare
There is no way I can reasonably satisfy code climate - if I use the guard clause, then I get flagged for the line length. |
I would suggest to remove the singleton altogether. Does it really add a substantial performance benefit? The code would be cleaner and more intuitive then. |
06d45b1
to
f5c9a3e
Compare
I removed the singleton as suggested. |
661966b
to
8b785da
Compare
According to the docs, calling MyPage.instance.header should get the header text for current locale. However, the associations are set up in a singleton for a default locale and never modified. The language-specific methods like MyPage.instance.header_en still work, but it would be nice to have fae handle the locale for us. This change checks for languages in fae_fields for page and dynamically changes the association if the locale change is detected.
8b785da
to
7a50cc2
Compare
Fixing tests, can't get around the line length/guard clause rules combo. |
@xprazak2 I'm sorry if the docs weren't clear, but auto-translating attrs is provided by the
This method is in a concern for user generated models and doesn't currently support The However, it would be possible to omit the base attr name here and then layer on a dynamic method similar to translated_attributes.each do |attribute|
define_method attribute.to_s do
self.send "#{attribute}_#{I18n.locale}"
end
end I'm going to close out this and open a ticket. I do like the refactoring you made in the model, so if you want to include that or and attempt at the above, I'll make it a priority. thanks! |
Adding |
According to the docs, calling MyPage.instance.header
should get the header text for current locale.
However, the associations are set up in a singleton
for a default locale and never modified.
The language-specific methods like MyPage.instance.header_en
still work, but it would be nice to have fae handle the locale
for us.
This change checks for languages in fae_fields for page
and dynamically changes the association if the locale change
is detected.