Files
grecia/app/controllers/concerns/translatable.rb
Senén Rodero Rodríguez 5dc0f7f054 Add :except and :only options to translatable_params method
Allow to choose among resource model translatable attributes.
2019-06-27 09:19:37 +02:00

16 lines
395 B
Ruby

module Translatable
extend ActiveSupport::Concern
private
def translation_params(resource_model, options = {})
attributes = [:id, :locale, :_destroy]
if options[:only]
attributes += [*options[:only]]
else
attributes += resource_model.translated_attribute_names
end
{ translations_attributes: attributes - [*options[:except]] }
end
end