On Oct 11, 3:03 am, Dennis Monsewicz <[email protected]> wrote:
> I have been trying to figure out how to fix a particular joins query to
> pull back everything from the query in the joined tables, but for some
> reason results only come back from either one table or the other.
>
> Code:
> p = Page.find(1, :joins => :page_translations, :conditions =>
> ['page_translations.page_id = ?', 1])
>
> The above will back everything from the pages table but nothing from the
> page_translations table.
>
> Code:
> p = PageTranslation.find(1, :joins => :page, :conditions =>
> ['page_translations.page_id = ?', 1])
>
> The above will back everything from the page_translations table but
> nothing from the pages table.
>
> I am needing to pull everything back from both tables.
>
> Thanks in advance for all the help!

AR defaults the select clause to pages.* (in the first case) but you
can override it if you want. beware about having multiple columns with
the same name selected (eg id) as they will stomp on each other

Fred
> --
> Posted viahttp://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