I have a joins table employees_roles as follows. I would like to get all employee_ids that has role_id 4, 5. Is it possible to do this through rails console or Is it possible to do that through map
employee_id role_id
1 3
2 4
3 4
4 4
5 5
6 5
7 5
8 4
9 4
10 4
11 4
I tried the following but this gives all the record from employee table
Employee.all.map{|e| e.roles.find_all {|role| [4, 5].include? role.id}}