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,11 +19,13 @@ class AsksController < ApplicationController
else
categories = Category.where(:id.in=>OrbitHelper.widget_categories).enabled
end
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
locale = I18n.locale
@ -132,11 +134,13 @@ class AsksController < ApplicationController
else
categories = Category.where(:id.in=>OrbitHelper.page_categories).enabled
end
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
first_category_id = category_ids.first