2012-12-05 46 views
3

嘿大家我是新手,並希望得到一些幫助保存區域設置翻譯到數據庫。全球化3 - 保存翻譯到數據庫

我有這種形式

= form_for @restaurant do |f| 
    = f.fields_for :en_info do |restaurant_en| 
    %h4 English Information 
    = restaurant_en.label :title 
    = restaurant_en.text_field :title 
    = restaurant_en.label :description 
    = restaurant_en.text_area :description 
    = f.fields_for :ar_info do |restaurant_ar| 
    %h4 Arabic Information 
    = restaurant_ar.label :title 
    = restaurant_ar.text_field :title 
    = restaurant_ar.label :description 
    = restaurant_ar.text_area :description 
    = f.submit 

並添加阿拉伯語表單字段有我可以用這個在我的控制器

def create 
    @restaurant = Restaurant.create params[:restaurant][:en_info] 
end 

創建方法模型保存到數據庫中,但是怎麼能之前我將阿拉伯語翻譯從表單保存到數據庫?

+1

檢查這個答案http://stackoverflow.com/questions/12142347/globalize3-two-translations-in-one-view這是關係到你的問題,也許你可以用同樣的方法來解決你的問題。 –

回答

0

嘗試使用globalize3_helpers gem。

= form_for @restaurant do |f| 

    - f.globalize_fields_for_locale :en do |l| 
    = l.input :title 
    = l.input :description, as: :text 

    - f.globalize_fields_for_locale :ar do |l| 
    = l.input :title 
    = l.input :description, as: :text