Files
nairobi/app/controllers/concerns/translatable.rb
Javi Martín 009cea29bf Validate translations in banners
This change forces us to use nested attributes for translations, instead
of using the more convenient `:"title_#{locale}"` methods.

On the other hand, we can use Rails' native `_destroy` attribute to
remove existing translations, so we don't have to use our custom
`delete_translations`, which was a bit buggy since it didn't consider
failed updates.
2018-11-05 18:19:50 +01:00

19 lines
413 B
Ruby

module Translatable
extend ActiveSupport::Concern
private
def translation_params(resource_model)
{
translations_attributes: [:id, :_destroy, :locale] +
resource_model.translated_attribute_names
}
end
def enabled_translations
params.fetch(:enabled_translations, {})
.select { |_, v| v == '1' }
.keys
end
end