User.find(:all, :include=>:articles, :conditions=>["articles.id in (?)", [a1.id, a2.id].join(',')])
AndyV wrote:
User.find(:all, :include=>:articles, :conditions=>["articles.id in (?)", [a1.id, a2.id].join(',')])
On Feb 26, 4:37 pm, Harry Seldon <rails-mailing-l...@andreas-s.net>
It works well. Thx a lot !
Congrats!
I tested this too quickly. Now that I come back to this it appears that it is actually not working.
The command User.find(:all, :include=>:articles, :conditions=>["articles.id in (?)", [a1.id, a2.id].join(',')]) returns the users who read one of the two articles but not only the users who read both.
Any idea of how to get simply the users who read both articles ?
Thx H
AndyV wrote:
Harry Seldon wrote:
Any idea of how to get simply the users who read both articles ?
Have a look at this thread:
Various solutions to effectively the same problem.
Thx, actually I have already seen this thread but clearly there is nothing "simple" in it.
This comes back to the question what is the SQL squery to get the users who read both articles.
For the moment I will simply do the intersection r1 & r2. It seems that Rails cannot do much for this question. So I will use SQL when I have some time.
Thx H
Mark Bush wrote: