Guest User

Untitled

a guest
Jan 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. Post.joins(:tags).where(:tags => { :id => [tag_ids] } )
  2.  
  3. GROUP BY posts.id
  4. HAVING count(tags.name) = 2
  5.  
  6. Post.joins(:tags).select('posts.id').where(:tags => { :id => [tag_ids] }
  7. ).having("count(tags.name) = ?", tag_ids.count).group('posts.id')
Add Comment
Please, Sign In to add comment