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 に答える