4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/batch_translation.rb', line 4
def globalize_fields_for(locale, *args, &proc)
raise ArgumentError, "Missing block" unless block_given?
@index = @index ? @index + 1 : 1
object_name = "#{@object_name}[translations_attributes][#{@index}]"
object = @object.translations.find_by_locale locale.to_s
@template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
@template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
if @template.respond_to? :simple_fields_for
@template.simple_fields_for(object_name, object, *args, &proc)
else
@template.fields_for(object_name, object, *args, &proc)
end
end
|