fix Role can't be blank error message on member_roles

pull/1186/head
Martin Linkhorst 12 years ago
parent fb7b0930c1
commit f75b531f1f
  1. 5
      app/controllers/projects_controller.rb
  2. 2
      app/models/user.rb

@ -266,7 +266,10 @@ private
def add_current_user_to_project_if_not_admin(project)
unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
m = Member.new do |member|
member.user = User.current
member.role_ids = [r].map(&:id) # member.roles = [r] fails, this works
end
project.members << m
end
end

@ -418,7 +418,7 @@ class User < Principal
# Return true if the user is a member of project
def member_of?(project)
!roles_for_project(project).detect {|role| role.member?}.nil?
roles_for_project(project).any?(&:member?)
end
# Returns a hash of user's projects grouped by roles

Loading…
Cancel
Save