Bharat Ruparel wrote: > Coach.find :all, :select => 'c.id, a.id, a.name', > :joins => 'as c inner join accounts as a on a.id = > c.account_id', > :order => 'a.name' > > It is only returning the following in irb: > > [#<Coach id: 99>] > > That is, it fails to return the account.id (or a.id) and account.name > (or a.name)
Given that you're not using :include => :account for efficiency reasons, you have to ensure that the account id does not override the coach id: Coach.find :all, :joins => :account, :order => 'accounts.name', :select => 'coaches.id, accounts.id as account_id, accounts.name' -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

