Displaying 1 result from an estimated 1 matches for "authors_name".
Did you mean:
author_name
2006 Apr 11
2
how to order by a related class???
Let''s suppose I have a books table and an authors table.
A book belongs to an author (to put things simply)
I want to browse the book list order by the author''s name.
In sql it would be like this (to make it clear)
select
b.id,
b.title,
a.id as authors_id
a.name as authors_name
from
books as b inner join authors as a on b.authors_id = a.id
order by a.name
the problem is that rails generates something like this
SELECT * FROM (
SELECT TOP 10 * FROM (
SELECT TOP 10 * FROM books ORDER BY title
) AS tmp1 ORDER BY title desc
) AS tmp2 ORDER BY title
see? no trace of...