app/models/incline/action_security.rb in incline-0.2.19 vs app/models/incline/action_security.rb in incline-0.2.20
- old
+ new
@@ -76,33 +76,34 @@
@valid_items ||=
begin
# remove all paths and set all items to hidden.
Incline::ActionSecurity.update_all(visible: false, path: '#')
- ret = Incline
- .route_list
- .reject{|r| %w(api locate).include?(r[:action]) }
- .map do |r|
-
+ Incline
+ .route_list
+ .reject{|r| %w(api locate).include?(r[:action]) }
+ .each do |r|
+
item = ActionSecurity.find_or_initialize_by(controller_name: r[:controller], action_name: r[:action])
-
+
# ensure the current path is set to the item.
item_path = "#{r[:path]} [#{r[:verb]}]"
if item.path == '#' || item.path.blank?
item.path = item_path
# only update the flags once if the path has not yet been set.
item.update_flags if update_flags
elsif !item.path.include?(item_path)
item.path += "\n" + item_path
end
-
+
# re-sort the path list and make the item visible.
item.path = item.path.split("\n").sort.join("\n")
item.visible = true
-
+
item.save!
- item
- end.sort do |a,b|
+ end
+
+ ret = Incline::ActionSecurity.where(visible: true).to_a.sort do |a,b|
if a.controller_name == b.controller_name
a.action_name <=> b.action_name
else
a.controller_name <=> b.controller_name
end