Closed smlabonia closed 2 years ago
I want to auto assign to users with a specific role on the project.
I tried with this code without success.
if new_record? arr = Array.new arr = User.find{(self.project_id) && (role==2)}.first
count = arr.count random_offset = rand(count) random_user = arr.offset(random_offset).first
@issue.assigned_to == random_user end
Could you help me please?
You fetch members incorrectly, I think. Try this:
#arr = User.find{(self.project_id) && (role==2)}.first members = project.users_by_role role = Role.find_by(id: 2) arr = members[role]
I want to auto assign to users with a specific role on the project.
I tried with this code without success.
if new_record? arr = Array.new arr = User.find{(self.project_id) && (role==2)}.first
count = arr.count random_offset = rand(count) random_user = arr.offset(random_offset).first
@issue.assigned_to == random_user end
Could you help me please?