12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/simple_navigation_acl/rules_controller.rb', line 12
def update
errors = []
resource_id = params[:id]
acl_item = params[:acl_item]
SimpleNavigationAcl::AclRule.where(id: resource_id).delete_all
acl_item.each do |context, |
.each do ||
rule = SimpleNavigationAcl::AclRule.find_or_create_by(id: resource_id, context: context, key: )
if rule.errors.present?
errors = errors + rule.errors.full_messages
end
end
end
respond_to do |format|
if errors.blank?
flash[:notice] = I18n.t(:save, default: ['Save Successfully'], scope: [:simple_navigation_acl, :messages])
format.html { redirect_to simple_navigation_acl_show_path(id: resource_id) }
format.json { render json: acl_item, status: :ok, location: simple_navigation_acl_show_path(id: resource_id) }
else
flash[:error] = errors.join(', ')
format.html { render :edit }
format.json { render json: errors, status: :unprocessable_entity }
end
end
end
|