Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

searching an array using another array of values in ruby

So I have an array which shows which levels are allowed to do things.

allowed = ["user", "admin"]

There's another array that shows which groups a user belongs to.

groups = ["user", "crazy"]

What's the best way to search the allowed array for ANY of the groups a user belongs to? I know it's easy but I'm drawing a real blank here...

like image 973
Ryan Avatar asked Jul 12 '26 05:07

Ryan


1 Answers

Just &:

allowed & groups


like image 176
Nakilon Avatar answered Jul 15 '26 00:07

Nakilon