Update archives_controller.rb

fix error
This commit is contained in:
chiu 2019-09-19 23:20:21 +08:00
parent dacaf2a18d
commit 08cbf76447
1 changed files with 6 additions and 4 deletions

View File

@ -17,9 +17,10 @@ class ArchivesController < ApplicationController
categories = files_by_cateogry.keys
all_categories_with_nil = ArchiveCategory.all.in(sort_number: nil)
all_categories_no_nil = ArchiveCategory.all.not_in(sort_number: nil).order_by(sort_number: 'desc')
categories_sort = all_categories_no_nil.concat(all_categories_with_nil).collect do |cat|
categories.select{|category| category.id.to_s == cat.category_id.to_s}[0]
all_categories_id = all_categories_no_nil.concat(all_categories_with_nil).collect do |cat|
cat.category_id.to_s
end
categories_sort = categories.select{|category| all_categories_id.include? category.id.to_s}[0]
cats_last = []
categories_sort.each do |category|
url_to_edit = ""
@ -81,9 +82,10 @@ class ArchivesController < ApplicationController
categories = files_by_cateogry.keys
all_categories_with_nil = ArchiveCategory.all.in(sort_number: nil)
all_categories_no_nil = ArchiveCategory.all.not_in(sort_number: nil).order_by(sort_number: 'desc')
categories_sort = all_categories_no_nil.concat(all_categories_with_nil).collect do |cat|
categories.select{|category| category.id.to_s == cat.category_id.to_s}[0]
all_categories_id = all_categories_no_nil.concat(all_categories_with_nil).collect do |cat|
cat.category_id.to_s
end
categories_sort = categories.select{|category| all_categories_id.include? category.id.to_s}[0]
cats = categories_sort.collect do |category|
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
archives = files_by_cateogry[category].collect do |archive|