嘿大家我是新手,很乐意帮助将语言环境翻译保存到数据库。
我有这个表格
= 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
但是如何将阿拉伯语翻译从表单保存到数据库?
答案 0 :(得分: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