ruby on rails - How globalize gem decides which content goes to translated table? -


in rails 4.2 app have set default locale setting in config/application.rb:

config.i18n.default_locale = :it 

i have simple "product" model

class product < activerecord::base     translates :name, :description end 

my need when i18n.locale = :it content should written in "products" table while others locales content shoud go in "product_translations" table. happens following:

if

config.i18n.default_locale = :en 

content written "products" table, different locales content goes "product_translations" table.

how can change this?

edit

using console test globalize behaviour found maybe did not understand how globalize should work. expecting "products" table filled default_locale (in case :it) , "product_translations" table filled other locales (:en, :fr, :de , on).

instead see whichever locale is, fields indicated

translates :name, :description 

are always written in "product_translations" , "product" table contains fields not translated (in case uom (unit of measure). output of console after saving new product :en locale.

[18] pry(main)> en_p=product.create(:name=>"butter",                                     :description => "82% min fat butter",                                      :uom => "kg")   (0.3ms)   begin  sql (0.7ms)     insert "products" ("uom", "created_at", "updated_at") values ($1, $2, $3) returning "id"     [     ["uom", "kg"],      ["created_at", "2015-07-14 05:49:09.097092"],      ["updated_at", "2015-07-14 05:49:09.097092"]   ] sql (0.7ms)   insert "product_translations" ("locale",                                        "name",                                        "description",                                        "product_id",                                        "created_at",                                        "updated_at")          values ($1, $2, $3, $4, $5, $6) returning "id"     [     ["locale", "en"],      ["name", "butter"],      ["description", "82% min fat butter"],      ["product_id", 5],      ["created_at", "2015-07-14 05:49:09.116683"],      ["updated_at", "2015-07-14 05:49:09.116683"]   ]   (15.9ms)   commit => #<product:0xb63d3568  id: 5,  name: "butter",  description: "82% min fat butter",  uom: "kg",  created_at: tue, 14 jul 2015 05:49:09 utc +00:00,  updated_at: tue, 14 jul 2015 05:49:09 utc +00:00>   [19] pry(main)> i18n.locale=:it => :it  [20] pry(main)> it_p=product.create(:name=>"olio di oliva evo",                                     :description => "olio di oliva extravergine spremuto freddo",                                      :uom => "kg") (0.4ms)   begin sql (0.5ms)     insert "products" ("uom", "created_at", "updated_at") values ($1, $2, $3) returning "id"     [     ["uom", "kg"],      ["created_at", "2015-07-14 05:51:34.772755"],      ["updated_at", "2015-07-14 05:51:34.772755"]   ] sql (0.8ms)   insert "product_translations" ("locale",                                        "name",                                        "description",                                        "product_id",                                        "created_at",                                        "updated_at")          values ($1, $2, $3, $4, $5, $6) returning "id"     [     ["locale", "it"],      ["name", "olio di oliva extravergine"],      ["description", "olio di oliva extravergine ottenuto unicamente per spremitura"],      ["product_id", 6],      ["created_at", "2015-07-14 05:51:34.779220"],      ["updated_at", "2015-07-14 05:51:34.779220"]   ]   (16.1ms)   commit => #<product:0xb6315ce8  id: 6,  name: "olio di oliva extravergine",  description: "olio di oliva extravergine ottenuto unicamente per spremitura",  uom: "kg",  created_at: tue, 14 jul 2015 05:51:34 utc +00:00,  updated_at: tue, 14 jul 2015 05:51:34 utc +00:00> 

is default behaviour? need remove translatable fields original table?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -