:join not working

David Modernfossil wrote:

I'm not following. How does this help me considering I want to order by rank which is not on the emails but it is on the codes table.

Gabe is saying that the :joins option is ignored for finds on HABTM associations.

So either write:

Email.find :all, :order => 'c.rank',             :conditions => "j.individual_id = #{individual.id}",             :joins => <<-END                as e inner join codes as c on e.type_cd = c.type_cd                inner join emails_individuals as j on e.id = j.email_id             END

or if you can somehow set up an Email.belongs_to :code association

individual.emails.find :all, :order => 'codes.rank', :include => :code