summaryrefslogtreecommitdiffstats
path: root/app/models/member.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-08 20:35:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-08 20:35:11 +0000
commit109d6de0c53dcf2d77d9daea8ab50947507f6ca2 (patch)
treee0a55d9a426154021d6eb3c9667ade64703577b9 /app/models/member.rb
parentf338fe9075e16de82a3bcbc860675d3404e8a774 (diff)
downloadredmine-109d6de0c53dcf2d77d9daea8ab50947507f6ca2.tar.gz
redmine-109d6de0c53dcf2d77d9daea8ab50947507f6ca2.zip
Adding a principal to 2 projects with member inheritance leads to an error (#25289).
Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@16381 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/member.rb')
-rw-r--r--app/models/member.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index 06b90bf55..b19f78c6b 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -184,9 +184,11 @@ class Member < ActiveRecord::Base
project_ids = Array.wrap(attributes[:project_ids] || attributes[:project_id])
role_ids = attributes[:role_ids]
project_ids.each do |project_id|
- members << Member.new(:principal => principal, :role_ids => role_ids, :project_id => project_id)
+ member = Member.find_or_new(project_id, principal)
+ member.role_ids |= role_ids
+ member.save
+ members << member
end
- principal.members << members
end
members
end