From: Tom Hughes Date: Mon, 10 Jun 2013 22:45:06 +0000 (+0100) Subject: Force notes list to be realised in notes#mine X-Git-Tag: live~4945 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/cc8bfc07bbb33debc746f83fdae71f02535592d8 Force notes list to be realised in notes#mine There is a rails bug which means that using count on a relation that uses uniq and offset/limit and which hasn't been realised yet will always return one, so force it to be realised. --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 3923cb2d0..f59e9974e 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -279,7 +279,7 @@ class NotesController < ApplicationController @description = t 'note.mine.subheading', :user => render_to_string(:partial => "user", :object => @this_user) @page = (params[:page] || 1).to_i @page_size = 10 - @notes = @this_user.notes.order("updated_at DESC, id").uniq.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author) + @notes = @this_user.notes.order("updated_at DESC, id").uniq.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author).all else @title = t 'user.no_such_user.title' @not_found_user = params[:display_name]