This commit is contained in:
BoHung Chiu 2023-01-26 11:45:42 +08:00
parent 7711a3183e
commit 0e9168634f
1 changed files with 12 additions and 8 deletions

View File

@ -19,10 +19,12 @@ class AsksController < ApplicationController
else
categories = Category.where(:id.in=>OrbitHelper.widget_categories).enabled
end
if (module_app.asc rescue true)
categories = categories.sort_by{|category| (category.sort_number.to_i rescue category.id)}
else
categories = categories.sort_by{|category| (-category.sort_number.to_i rescue category.id)}
unless Category.respond_to?(:sorted)
if (module_app.asc rescue true)
categories = categories.sort_by{|category| (category.sort_number.to_i rescue category.id)}
else
categories = categories.sort_by{|category| (-category.sort_number.to_i rescue category.id)}
end
end
tags = module_app.tags
ask_question = AskQuestion.new
@ -132,10 +134,12 @@ class AsksController < ApplicationController
else
categories = Category.where(:id.in=>OrbitHelper.page_categories).enabled
end
if (module_app.asc rescue true)
categories = categories.sort_by{|category| (category.sort_number.to_i rescue category.id)}
else
categories = categories.sort_by{|category| (-category.sort_number.to_i rescue category.id)}
unless Category.respond_to?(:sorted)
if (module_app.asc rescue true)
categories = categories.sort_by{|category| (category.sort_number.to_i rescue category.id)}
else
categories = categories.sort_by{|category| (-category.sort_number.to_i rescue category.id)}
end
end
category_ids = categories.collect{|v| v.id.to_s}
ask_settings = AskCategorySetting.enabled.where(:category_id.in=> category_ids).to_a