How come I can do a find on one array, but not another?
I understand the Array class has no find and AR class does, so how does
this work?
My alternative to using find is to use ‘each’ on the array and check for
matching records, it works, but does this look correct?
def has_permission?(controller, action)
for p in self.permissions do
if p.controller == controller && p.action == action
return true
end
end
return false
end
def permissions
self.user_groups.collect {|o| o.permissions}.flatten.uniq
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.