Description
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.