51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'app/controllers/admin/roles_controller.rb', line 51
def update
return unless get_and_verify_role
if params[:role]
fp_params = params[:role].delete(:feature_permissions) || []
else
fp_params = []
end
@features = Feature.all
success = false
if success = @role.update_attributes(params[:role])
@role.features = []
fp_params.each do |fp|
next if fp['feature_id'].blank?
read_only = fp['read_only'] == fp['feature_id']
@role.feature_permissions << FeaturePermission.new(fp.merge(:role => @role, :read_only => read_only))
end
success = @role.save
end
if success
redirect_to(admin_role_url(@role), :notice => 'Role was successfully updated.')
else
render :action => 'edit'
end
end
|