4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/authengine/action_roles_controller.rb', line 4
def update_all
aa = ActionRole.all.group_by(&:role_id).inject({}){|hash,a| hash[a[0]]=a[1].collect(&:action_id); hash}
params[:permission].each do |role_id,permissions| role_id = role_id.to_i
permissions.each do |action_id, val|
action_id = action_id.to_i
a = aa[role_id].nil? ? false : aa[role_id].include?(action_id) if val=="1" && !a ActionRole.new(:role_id=>role_id,:action_id=>action_id).save
elsif val=="0" && a ActionRole.find_by_role_id_and_action_id(role_id,action_id).delete
end
end
end
redirect_to authengine_actions_url
end
|