From a945fc0fcd4e12691858b4bf181297d9e399dee0 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 10 May 2013 22:32:14 +0100 Subject: [PATCH] Fix trace lists to correctly respect tag restrictions --- app/controllers/trace_controller.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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") -- 2.43.2