Closed koren85 closed 4 years ago
Hi,
You get an error, because you're using an assigned user for membership and the interpreter also thinks of the possibility of what happens if the assigned user is not specified. In this case, you want to get membership for nil.
Try this code, it should work:
if self.assigned_to
c_role_ids = User.current.membership(self.tracker_id).try(:role_ids) || []
u=User.find(self.assigned_to)
a_role_ids = u.membership(self.tracker_id).try(:role_ids) || []
if c_role_ids.include? 6
if a_role_ids.include? 3
raise WorkflowError.new("Error")
end
end
end
I hope its help!
Hi, Yes, it helped me. Thank you so much!
I get Error when I use this code in before_save:
Eror then I save rule:
undefined method `membership' for nil:NilClass``
but in ruby console I get rusult
What I do wrong?