3

Hey everyone I'm newbie and would love to get some help with saving locale translation to database.

I have this form

= 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

And before adding the Arabic form fields there I was able to save the model to the database using this create method in my controller

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

But how can I save the Arabic translation from the form to database?

Liban
  • 31
  • 1
  • 1
    Check this answer http://stackoverflow.com/questions/12142347/globalize3-two-translations-in-one-view which is related to your question and probably you can use the same approach to solve your problem. – Paulo Fidalgo May 07 '13 at 13:24

1 Answers1

0

Try using 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
Leftis
  • 119
  • 9