I have a User model that has a Roles collection.
The Roles collection has columns like:
id, name, ....
I am now looping through another collection, and I would to create a new collection if the role_id’s match, so:
SomeOtherCollection.each do |i|
@blah << i if self.Roles.contains i.role_id
end
Contains doesn’t exist, how can I do this?
The faster method the better since this will happen allot.
Assuming
Roleis an ActiveRecord model and you mean to callself.roles, notself.Roles, and you’re using Rails 3:Side note: cancan is a really great authorization gem that you might find useful.