Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## TODO: There has *got* to be another way to do this. It's ridiculous.
- def all_by_tags some_tags
- query = []
- some_tags.each do |tag|
- query << 'SELECT taggings.post_id FROM tags LEFT JOIN taggings ON tags.id = taggings.tag_id WHERE tags.name = ?'
- end
- post_ids = database.query([query.join(" UNION "), some_tags].flatten)
- Post.all(post_ids)
- end
Add Comment
Please, Sign In to add comment