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

在添加阿拉伯语表单字段之前,我可以在我的控制器中使用这个 create 方法将模型保存到数据库中

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

但是如何将阿拉伯语翻译从表单保存到数据库?

4

1 回答 1

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
于 2013-09-16T14:09:02.083 回答