I’m trying to join two tables with active record and not getting what I
expect *surprise*.

Two tables T1 and T2, both have a common key called ID.  Given this
relationship in the Models

class T1 < ActiveRecord::Base
  has_one :T2

class T1 < ActiveRecord::Base
  belongs_to :T1

In the controller I have…
  @results = T1.all(:joins => :T2)
  @results only contains the columns from T1 and none from T2.

If I do a find_by_sql as follows
  @results = T1.find_by_sql("select * from T1, T2 where T1.id = T2.id")
  @results contains the correct Cartesian product of T1, T2.

Am I missing something in the active record call?

Thanks in advance for your time...
jeff...

-- 
Posted via http://www.ruby-forum.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.

Reply via email to