From 2ec251249d62298f974c3945ec9b88afa5997310 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 18 Feb 2014 17:10:31 +0000 Subject: Handle the case where the current locale isn't in site list We only really want to redirect people to live sites, so pre-launch sites don't belong in WorldFOIWebsites. Handle the case where the current locale isn't there. Closes #1345. --- app/controllers/services_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/controllers/services_controller.rb') diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 78c494dba..97c47c448 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -17,8 +17,15 @@ class ServicesController < ApplicationController text = _("Hello! You can make Freedom of Information requests within {{country_name}} at {{link_to_website}}", :country_name => found_country[:country_name], :link_to_website => "#{found_country[:name]}".html_safe) else - current_country = WorldFOIWebsites.by_code(iso_country_code)[:country_name] - text = _("Hello! We have an important message for visitors outside {{country_name}}", :country_name => current_country) + country_data = WorldFOIWebsites.by_code(iso_country_code) + if country_data + text = _("Hello! We have an important message for visitors outside {{country_name}}", + :country_name => country_data[:country_name], + :url => "/help/alaveteli?country_name=#{CGI.escape(country_data[:country_name])}") + else + text = _("Hello! We have an important message for visitors in other countries", + :url => "/help/alaveteli") + end end ensure FastGettext.locale = old_fgt_locale -- cgit v1.2.3