X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/7ccd11ebf3c8e119a04119a2e89ce6a879560578..ac6a872a48c2663524fb2884724524f11ab671c9:/app/controllers/site_controller.rb diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 471e9f3c5..3a69eed12 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -77,26 +77,30 @@ class SiteController < ApplicationController ) end - if params[:node] - bbox = Node.find(params[:node]).bbox.to_unscaled - @lat = bbox.centre_lat - @lon = bbox.centre_lon - @zoom = 18 - elsif params[:way] - bbox = Way.find(params[:way]).bbox.to_unscaled - @lat = bbox.centre_lat - @lon = bbox.centre_lon - @zoom = 17 - elsif params[:note] - note = Note.find(params[:note]) - @lat = note.lat - @lon = note.lon - @zoom = 17 - elsif params[:gpx] && current_user - trace = Trace.visible_to(current_user).find(params[:gpx]) - @lat = trace.latitude - @lon = trace.longitude - @zoom = 16 + begin + if params[:node] + bbox = Node.visible.find(params[:node]).bbox.to_unscaled + @lat = bbox.centre_lat + @lon = bbox.centre_lon + @zoom = 18 + elsif params[:way] + bbox = Way.visible.find(params[:way]).bbox.to_unscaled + @lat = bbox.centre_lat + @lon = bbox.centre_lon + @zoom = 17 + elsif params[:note] + note = Note.visible.find(params[:note]) + @lat = note.lat + @lon = note.lon + @zoom = 17 + elsif params[:gpx] && current_user + trace = Trace.visible_to(current_user).find(params[:gpx]) + @lat = trace.latitude + @lon = trace.longitude + @zoom = 16 + end + rescue ActiveRecord::RecordNotFound + # don't try and derive a location from a missing/deleted object end end @@ -126,7 +130,7 @@ class SiteController < ApplicationController :style_src => %w['unsafe-inline'] ) - render "id", :layout => false + render :layout => false end private