Here's the line of code that is now the bane of my existance: @topic_pages, @topics = paginate(:topics, :include => :posts, :order => 'posts.created_at asc')
So, grab topics (eager loading the posts) and then order the topics based on the post created date. This doesn't work because when paginate tries to count the records, it -does- try to order them by posts.created_at but does not include posts in the query. I'd like to write some test cases and fix the bug, but interestingly enough, there are no pagination tests in ActionPack. They just aren't there. In fact, if you 'grep -r "paginate" *' in your rails directory, you won't see any tests for pagination anywhere in the core. I'm going to write the pagination tests I guess, since I need them now. Unfortunately, I need an ActiveRecord connection in ActionPack in order to test this. It seems that test/active_record_assertions_test.rb needs AR as well, but the code to connect is messy and localized to that file. I've written a patch (http://dev.rubyonrails.org/ticket/3606) extracting the ActiveRecord connection and fixture model loading (not the data, which currently isn't loaded in ActionPack either) to a helper class. All tests pass (without modifications) except two. These two assertions are that the company model (defined in AR/fixtures) should error out when rating = 2. This is residual from changeset #4 (http://dev.rubyonrails.org/browser/trunk/actionpack/test/controller/active_record_assertions_test.rb?rev=4) so I've taken the liberty of writing a hacky setup/reset company helper which is run in setup/teardown for the tests where it matters. All tests now pass. If anyone has widespread objections to this, please raise them ASAP. I'd like to start writing pagination tests so I can fix my original bug and want to base the connection code on my helper. _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core