]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/trace_controller.rb
Rework the pagination of the trace list to avoid having to count
[rails.git] / app / controllers / trace_controller.rb
index 3769202da1b5026d597b2d91a011109991d88a78..ea107c2b5852579d802e67b191178ffd8f118afb 100644 (file)
@@ -81,11 +81,15 @@ class TraceController < ApplicationController
     conditions[0] += " AND gpx_files.visible = ?"
     conditions << true
 
-    @trace_pages, @traces = paginate(:traces,
-                                     :include => [:user, :tags],
-                                     :conditions => conditions,
-                                     :order => "gpx_files.timestamp DESC",
-                                     :per_page => 20)
+    @page = (params[:page] || 1).to_i
+    @page_size = 20
+
+    @traces = Trace.find(:all,
+                         :include => [:user, :tags],
+                         :conditions => conditions,
+                         :order => "gpx_files.timestamp DESC",
+                         :offset => (@page - 1) * @page_size,
+                         :limit => @page_size)
 
     # put together SET of tags across traces, for related links
     tagset = Hash.new