Hi guys I know that this is really bad idea but I want join three tables for my query on polymorphic association
for example
class Article
has_many :comments, :as=>:commentable
end
class Post
has_many :comments, :as=>:commentable
end
class Comment
belongs_to :commentable, :polymorphic=>:true
end
and I need to get something similar to
Comment.all(:joins=>:commentable)
of course I can't write exactly such join but I need something that can join this three tables
I'm writing cimplicate search by several tables User can choose different options Let's say that User has_one Comment
and I want select all users who commented something (Article or Post) that includes some phrase So I need something similar to User.all(:joins=>{:comments=>:commentable}, :conditions=>["articles.body LIKE (?) OR posts.header LIKE (?)", value, value])