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

Rails 6 "working" #39

Open
henriquekraemer opened this issue May 28, 2019 · 1 comment
Open

Rails 6 "working" #39

henriquekraemer opened this issue May 28, 2019 · 1 comment

Comments

@henriquekraemer
Copy link

Looks like this gem wont be supported anymore. So, if anybody tries to use this on rails 6, here it goes:

My gem set:

  • rails (6.0.0.rc1)
  • globalize (5.3.0)
  • globalize-accessors (0.2.1)

model -> globalize_accessors

The :locales and :attributes options are optional. Their default values are:

:locales => I18n.available_locales
:attributes => translated_attribute_names

Apparently, the defaults ain't working, you should define yourself!

globalize_accessors :locales => I18n.available_locales, :attributes => translated_attribute_names
class FaqCategory < ApplicationRecord
	translates :description, touch: true
	globalize_accessors :locales => I18n.available_locales, :attributes => translated_attribute_names
end

controller -> globalize_accessors
Strong parameters aren't working either.

Example with strong parameters:

params.require(:product).permit(*Product.globalize_attribute_names)
If you need to permit non-translatable attributes as well, you could include them with:

permitted = Product.globalize_attribute_names + [:position]
params.require(:product).permit(*permitted)

You can "workaround" with:

params.permit(*FaqCategory.globalize_attribute_names)

In my case, I'm building a simple FAQ API for our application, so this won't be an issue.

@maelevadili
Copy link

maelevadili commented Aug 26, 2020

Henrique's solution works fine 👍
In my case I also used the batch_translations gem to handle all my model attributes translations in one single form.

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

No branches or pull requests

2 participants