项目成员编辑 添加事务

This commit is contained in:
huang 2016-12-19 17:08:32 +08:00
parent 05d10e20d1
commit 7faddc30c5
1 changed files with 18 additions and 15 deletions

View File

@ -301,9 +301,9 @@ class MembersController < ApplicationController
#增加对课程成员修改的支持 #增加对课程成员修改的支持
if @project if @project
if params[:membership] if params[:membership]
ActiveRecord::Base.transaction do
begin
@member.role_ids = params[:membership][:role_ids] @member.role_ids = params[:membership][:role_ids]
#added by nie
if (params[:membership][:role_ids]) if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0]) role = Role.find(params[:membership][:role_ids][0])
if role.allowed_to?(:is_manager) if role.allowed_to?(:is_manager)
@ -318,9 +318,12 @@ class MembersController < ApplicationController
end end
end end
end end
@member.save!
rescue Exception => e
puts e
end
end
end end
saved = @member.save
respond_to do |format| respond_to do |format|
format.html { redirect_to_settings_in_projects } format.html { redirect_to_settings_in_projects }
format.js format.js