Project

General

Profile

Member selection chain

Added by Brad Beattie about 15 years ago

Given a set of projects, I'm trying to find any user that has a specific permission on any of those projects. Below is the code I thought would work.

@projects.collect(&:members).select {|m| m.role.allowed_to?(:view_schedules)}.collect {|m| m.user}.flatten.uniq

Unfortunately, this is giving me the following error.

undefined method `role' for #<Class:0x7ff2c55c8d88>

Any suggestions?


Replies (1)

RE: Member selection chain - Added by Brad Beattie about 15 years ago

Seems this did the trick.

@users = @projects.collect{|p| p.members }.flatten.select {|m| m.role.allowed_to?(:view_schedules)}.collect {|m| m.user}.uniq

    (1-1/1)