]> git.openstreetmap.org Git - rails.git/commitdiff
Fix trace lists to correctly respect tag restrictions
authorTom Hughes <tom@compton.nu>
Fri, 10 May 2013 21:32:14 +0000 (22:32 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 10 May 2013 21:48:26 +0000 (22:48 +0100)
app/controllers/trace_controller.rb

index cc5d9a07164d0e049b9d7f34b915837a0da7c26e..69cd9866ee8cc1cc083fc719538501f8062d4eaa 100644 (file)
@@ -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")