I have a set of 2 fields (title, description) and some locales (English,Swedish) for translation.
When you visit the page you can only see English set fields. But, user must be able to provide additional translations (if he wants). For that purpose I use "globalize3" and "batch_translations" (https://github.com/fidel/batch_translations) gems.
Language selection is done like a dropdown list. Once you select a language, new set of fields should appear just below the previous set.
Problem itself kinda resembles the one Ryan covered in his screencasts: http://railscasts.com/episodes/197-nested-model-form-part-2
BUT, there is one major difference - forms must be translated as well.
At first, I thought that everything is OK, I won't have any problems passing a form builder reference to my controller's remote action, that is responsible for rendering the partial with selected locale and embedding it.
But, it turned out that there is no possibility to pass the reference by object_id (Garbage Collector destroy's it).
Then I found that you can instantiate the FormBuilder in controller, something like this:
f = ActionView::Helpers::FormBuilder.new(:name, @object, view_context, {}, nil)
If I do so, only first-order fields are working, like this: f.text_field
But, globalize3 and batch_translations are using nested_attributes:
<% f.globalize_fields_for locale do |g| %>
g.text_field :title
g.text_area :description
<% end %>
And for some reason (I think it is because of the incorrect view_context), system throws an error:
ActionView::Template::Error (undefined method `<<' for nil:NilClass)
Any good solution to this problem ? Thanks!