Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. def self.combined_tasks(tag_ids)
  2. tasks = []
  3. tag_ids.each do |tag_id|
  4. tasks << self.find(tag_id).tasks
  5. end
  6.  
  7. tasks.inject { |result, elem| result & elem }
  8. end
  9.  
  10. def self.in_all_tags(tags_ids)
  11. tags = Tag.combined_tasks(tag_ids)
  12. end
  13.  
  14. Task.joins(:tag_tasks).where(tag_tasks: {tag_id: tag_ids}).uniq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement