Forum: Ruby on Rails Problem with find and join (wrong id?)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
christer.nilsson (Guest)
on 2005-11-14 01:32
(Received via mailing list)
This statement works correct in my controller (list action):

@reports = Report.find_by_sql("SELECT r.* FROM reports AS r INNER JOIN
Users AS u ON r.user_id = u.id WHERE " + cond + " ORDER BY
flightnumber, flightdate")

This statement does not:

@reports = Report.find(:all, :order => "flightnumber, flightdate",
:conditions => cond, :joins => "AS r INNER JOIN Users AS u ON
r.user_id = u.id")

All the ID:s in Show are the same for every record!
It seems u.id is used instead of r.id as the report identifier.

What am I doing wrong?
This topic is locked and can not be replied to.