你可以这样做:
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… 或发送邮件给我。
希望这能帮到你!