Project

General

Profile

Defect #32935 » member.rb.patch

Pavel Rosický, 2020-02-03 00:42

View differences:

member.rb (working copy)
64 64
    ids = (arg || []).collect(&:to_i) - [0]
65 65
    # Keep inherited roles
66 66
    ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
67

  
68
    new_role_ids = ids - role_ids
69
    # Add new roles
70
    new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id, :member => self) }
71 67
    # Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
72 68
    member_roles_to_destroy = member_roles.select {|mr| !ids.include?(mr.role_id)}
73 69
    if member_roles_to_destroy.any?
74 70
      member_roles_to_destroy.each(&:destroy)
75 71
    end
72
    member_roles.reload
73
    # Add new roles
74
    super(ids)
76 75
  end
77 76

  
78 77
  def <=>(member)
    (1-1/1)