Skip to content

Commit

Permalink
fixup! c2e1f22 reject translations that are not available
Browse files Browse the repository at this point in the history
Bleeerrghhh. Only select translations that are available for admin
public body form. Not sure if it can happen in production but if e.g.
you change the AVAILABLE_LOCALES it tries to sort existing translations
by the new AVAILABLE_LOCALES and fails because the key no longer exists.
  • Loading branch information
garethrees committed Feb 17, 2015
1 parent 9f68075 commit 81227a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/views/admin_public_body/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div id="div-locales">
<ul class="locales nav nav-tabs">
<% @public_body.translations.sort_by{ |t| I18n.available_locales.index(t.locale) }.each do |translation| %>
<% @public_body.translations.select{ |t| I18n.available_locales.include?(t.locale) }.sort_by{ |t| I18n.available_locales.index(t.locale) }.each do |translation| %>
<li>
<a href="#div-locale-<%= translation.locale.to_s %>" data-toggle="tab">
<%= locale_name(translation.locale.to_s) || _("Default locale") %>
Expand All @@ -14,7 +14,7 @@
</ul>

<div class="tab-content">
<% @public_body.translations.sort_by{ |t| I18n.available_locales.index(t.locale) }.each do |translation| %>
<% @public_body.translations.select{ |t| I18n.available_locales.include?(t.locale) }.sort_by{ |t| I18n.available_locales.index(t.locale) }.each do |translation| %>
<% if translation.locale.to_s == I18n.default_locale.to_s %>
<%= fields_for('public_body', @public_body) do |t| %>
<%= render :partial => 'locale_fields', :locals => { :t => t, :locale => translation.locale } %>
Expand Down

0 comments on commit 81227a0

Please sign in to comment.