Class: GroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/groups_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_route, #current_ability, #set_current_user

Instance Method Details

#createObject

权限设置汤建华



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/groups_controller.rb', line 5

def create
  role = Role.find params[:role_id]
  if params[:function_id]
    function_ids=params[:function_id]
    Group.transaction do
      Group.delete_all(:role_id => role.id)
      function_ids.each do |function_id|
        function= Function.find(function_id)
        Group.create(:role_id => role.id, :function_id => function.id)
      end
    end
  end
  redirect_to roles_path
end