Paginate include => :last and order by value


Why does it seem like I’m having so much trouble with this?

I created a topics table, and a replies table. In my Topic model I used
the following lines of code:

has_many :replies
has_one :first_reply, :class_name => ‘Reply’, :order => “created_on”
has_one :last_reply, :class_name => ‘Reply’, :order => “created_on DESC”

Thought I would be good at this point to paginate like so, where the
created_on value is in the replies table:

@topic_pages, @topics = paginate :topics, :per_page => 10, :include =>
:last_reply, :order => “created_on DESC”

This doesn’t display all 10 topics though, for instance if the hottest
topic has more than 9 replies it will only show that one topic. Seems
that my code is pulling all of the replies for each topic from the
database instead of just the last one.

I don’t think Active Record is taking into account my :has_one
declaration, any thoughts on how to fix this? Thank you.