Forum: Ruby on Rails Will_paginate with include option

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ank A. (Guest)
on 2009-01-10 19:10
  I am using will_paginate and want to use eager loading. but when i use
the include and order option i get an error. I am using mssqlserver2000
as database

 @people =
Person.paginate(:include=>[:relations],:conditions=>[' NOT IN
(Select person_id from
ASC, first_name ASC')

DBI::DatabaseError: Execute
    OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
      ORDER BY items must appear in the select list if SELECT DISTINCT
is specified.
    HRESULT error code:0x80020009
Exception occurred.: SELECT DISTINCT TOP 20 FROM people  LEFT
OUTER JOIN people_relations ON people_relations.person_id =
LEFT OUTER JOIN relations ON = people_relations.relation_id
WHERE ( NOT IN (Select person_id from people_relations))  ORDER
BY last_name ASC, first_name ASC

but when i remove the include option it works fine but the results are
not sorted. Please help by last_name.
Thank you.
This topic is locked and can not be replied to.