Use Hash#dig to simplify code
[rails.git] / app / helpers / browse_helper.rb
index 0470d41a25ea49f0e34ba8d2c10175af7f9fb02d..c4ce41b064df9550fb0113ec9b628a4120f74189 100644 (file)
@@ -114,17 +114,9 @@ module BrowseHelper
     # the correct page.
     lookup_us = lookup.tr(" ", "_")
 
-    if page = begin
-                WIKI_PAGES[locale][type][lookup_us]
-              rescue
-                nil
-              end
+    if page = WIKI_PAGES.dig(locale, type, lookup_us)
       url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
-    elsif page = begin
-                   WIKI_PAGES["en"][type][lookup_us]
-                 rescue
-                   nil
-                 end
+    elsif page = WIKI_PAGES.dig("en", type, lookup_us)
       url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
     end