次のように操作してコンソールにアクセスします。
cd /var/discourse
./launcher enter app
rails c
その後、do stuffを実行します。
これらが理解できない場合は、自分で実行したくはないでしょう。
以下は、2018 年 1 月 12 日頃に動作したと思われるスクリプトです。動作を保証するものではありませんが、問題ないはずです。バックアップを取得し、ろうそくを灯してください。![]()
# 検索に一致するカテゴリとサブカテゴリをアルファベット順に並べ替える
def sort_matching_categories_and_subcategories(search)
categories = Category.where("name like ?", search)
position = 100
categories.order(:name).each do |cat|
position += 5
cat.position = position
cat.save!()
c_position = 0
children = Category.where(:parent_category_id => cat.id)
children.order(:name).each do |c|
c_position += 5
c.position = c_position
c.save!()
end
end
end
# 検索に一致する特定のカテゴリのサブカテゴリをアルファベット順に並べ替える
def sort_matching_subcategories(search)
categories = Category.where("name like ?", search)
if categories.count > 1
puts "Found more than one category"
end
categories.order(:name).each do |cat|
c_position = 5
children = Category.where(:parent_category_id => cat.id)
children.order(:name).each do |c|
c_position += 5
c.position = c_position
c.save!()
end
end
end
それ以上のサポートが必要で予算がある場合は、Redirecting… を参照するか、メールでお問い合わせください。
お役に立てれば幸いです!