how do I join and include the association
Posted
by Mark
on Stack Overflow
See other posts from Stack Overflow
or by Mark
Published on 2010-02-26T01:38:27Z
Indexed on
2010/03/30
12:03 UTC
Read the original article
Hit count: 306
ruby-on-rails
Hi All,
How do I use both include
and join
in a named scope?
Post is polymorphic
class Post
has_many :approved_comments, :class_name => 'Comment'
end
class Comment
belongs_to :post
end
Comment.find(:all, :joins => :post, :conditions =>
["post.approved = ? ", true], :include => :post)
This does not work as joins
does an inner join, and include
does a left out join.
The database throws an error as both joins can't be there in same query.
© Stack Overflow or respective owner