From: Tom Hughes Date: Fri, 10 May 2013 21:32:14 +0000 (+0100) Subject: Fix trace lists to correctly respect tag restrictions X-Git-Tag: live~4998 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/a945fc0fcd4e12691858b4bf181297d9e399dee0?ds=sidebyside Fix trace lists to correctly respect tag restrictions --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index cc5d9a071..69cd9866e 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -66,13 +66,7 @@ class TraceController < ApplicationController end if params[:tag] - @tag = params[:tag] - - files = Tracetag.where(:tag => params[:tag]).select(:gpx_id).all - - if files.length > 0 - @traces = @traces.where(:id => files.collect { |tt| tt.gpx_id }) - end + @traces = @traces.tagged(params[:tag]) end @page = (params[:page] || 1).to_i @@ -222,7 +216,7 @@ class TraceController < ApplicationController end if params[:tag] - traces = traces.where("EXISTS (SELECT * FROM gpx_file_tags AS gft WHERE gft.gpx_id = gpx_files.id AND gft.tag = ?)", params[:tag]) + traces = traces.tagged(params[:tag]) end traces = traces.order("timestamp DESC")