From 12f6f06ade07ba33f4d9d0ee9e453a2b66cc6948 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 27 Jul 2018 01:50:51 +0200 Subject: [PATCH] Fix exception when using locale as a parameter in the url When visiting, for example, /admin/site_customization/information_texts?locale=fr we were getting an `UncaughtThrowError: uncaught throw :exception` With the following payload ``` File "/aytomad/app/participa/participacion/releases/20180726231929/app/views/admin/site_customization/information_texts/_form_field.html.erb" line 5 File "/aytomad/app/participa/participacion/releases/20180726231929/app/helpers/globalize_helper.rb" line 35 in block in globalize ``` Substituting this line seems to solve it Note that we had to remove the portuguese local too, as it was giving a different exception due to this change. This problem, has been solved in the original globalization PR --- app/models/i18n_content.rb | 2 +- .../site_customization/information_texts/_form_field.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/i18n_content.rb b/app/models/i18n_content.rb index d7914c83a..8d130539b 100644 --- a/app/models/i18n_content.rb +++ b/app/models/i18n_content.rb @@ -6,6 +6,6 @@ class I18nContent < ActiveRecord::Base validates :key, uniqueness: true translates :value, touch: true - globalize_accessors locales: [:en, :es, :fr, :nl, :val, :pt_br] + globalize_accessors locales: [:en, :es, :fr, :nl, :val] end diff --git a/app/views/admin/site_customization/information_texts/_form_field.html.erb b/app/views/admin/site_customization/information_texts/_form_field.html.erb index 4ae31adec..09227feaf 100644 --- a/app/views/admin/site_customization/information_texts/_form_field.html.erb +++ b/app/views/admin/site_customization/information_texts/_form_field.html.erb @@ -2,7 +2,7 @@ <%= hidden_field_tag "contents[content_#{content.key}][id]", content.key %> <%= text_area_tag "contents[content_#{content.key}]values[value_#{locale}]", I18nContent.where(key: content.key).first.try(:value) || - I18n.backend.translate(locale, content.key), + t(content.key, locale: locale), { rows: 5, class: "js-globalize-attribute", style: display_translation?(locale),