Papipo/mongoid_i18n — Issue #21: Cannot create new record from hash
Author: newstler
Created: 2012-01-31 20:57:32+00:00
State: open

Hello,

I have a `Category` model with `localized_field :name`

In my `_form.html.erb` file I have

<% current_locale = I18n.locale %>
<% @template.available_locales.sort_by { |e| [ e == @template.default_locale ? 0 : 1, e ] }.each do |locale| %>

<%= f.label :name, t(:name).capitalize + " /" + t(:locale_native_name, :locale => locale) + " (" + t(:locale_name, :locale => locale) + ")/" %>

<% I18n.locale = locale %>
<%= f.text_field :name, :name => "category[name][#{locale}]" %>
<% I18n.locale = current_locale %>

<% end %>

Which sends to server

Parameters: {"utf8"=>"✓", "authenticity_token"=>"zyMbqRTW+6HJy4SoCg4vmzLA6pGUtmzU1PqOr7kcGGc=", "category"=>{"name"=>{"ru"=>"aaa", "en"=>"zzz"}}, "commit"=>"Сохранить", "locale"=>"ru"}

It always worked, but now it stores data like this:

#{"ru"=>"aaa", "en"=>"zzz"}}>

I used this technique in previous projects, but now I just don't understand what's wrong and why it works like this.