stefkas
stefkas

Reputation: 81

Globilize updates all translations, except the 'title'

I'm using Globalize 3.1 and globalize-accessors on an old rails 3.2 project, in order to store some translated fields, in 3 languages. I have two models, a Company with many basic details [title, address, lat, lng, image etc], where I translate the 'title' and a Description with two fields [summary and description], where I translate both the 'summary' and 'description'.

I'm using simple_forms to add all translated fields in my admin, in [:en, :de, :it] locales.

Everything stores and updates without any problem, but the 'title_en' from the Company remains the initial, so I cannot change it if I want.

in Company model

translates :title
globalize_accessors locales: [:en, :de, :it], attributes: [:title]

in Controller

permitted = [:title_en, :title_de, :title_it, :address, :lat, :lng, 
{ description_attributes: [ :summary_en, :description_en, :summary_de, :description_de, :summary_it, :description_it ] }, ....

in my View

   <strong>English Translation:</strong>
    <%= f.input :title_en %>
    <%= f.simple_fields_for :description do |p| %>
     <%= p.input :summary_en %>
     <%= p.input :description_en, :as => :text, :input_html => { :rows => 20 } %>
    <% end %>
   <hr>
   <strong>Italian Translation:</strong>
    <%= f.input :title_it %>
    <%= f.simple_fields_for :description do |p| %>
     <%= p.input :summary_it %>
     <%= p.input :description_it, :as => :text %>
    <% end %>
   <hr>

I have double check every possible misspell or error, but the problem remains, no matter if I'm just adding the empty translation to a Company, or I have already filled all translated fields. The 'title_en' remains always the same. All other fields (title_it, title_de, summary_en, description_en, description_it etc) can be updated without any issue.

Do you have any idea? Thank you!

****** Additional Info ******* This is my Update Action

  def update
    expire_fragment(params[:id])
    return update_rates if params[:company][:rates_attributes]
    respond_with @company = Company.update(params[:id], company_params), location: admin_companies_url
  end

def company_params
  permitted = [:title_en, :title_de, :title_it, :address, :lat, :lng, .....
  { description_attributes: [ :summary_en, :description_en,    :summary_de, :description_de, :summary_it, :description_it ] },
  { rates_attributes: [:id, :status, :date, :price] },   :images_attributes,:amenity_ids]
  params.require(:company).permit(*permitted)
end

Upvotes: 0

Views: 51

Answers (1)

Alex Baidan
Alex Baidan

Reputation: 1075

   <strong>English Translation:</strong>
<%= f.input :title_it %>

Line 2 = :title_it

Upvotes: 1

Related Questions