Clean Topic#slug when SiteSetting.slug_generation_method changes.

https://meta.discourse.org/t/removing-the-concept-of-slugs-for-some-languages/26643/24?u=tgxworld
This commit is contained in:
Guo Xiang Tan
2017-12-13 16:09:21 +08:00
parent dee498a281
commit d5293aeae2
2 changed files with 28 additions and 0 deletions

View File

@@ -33,6 +33,14 @@ class Topic < ActiveRecord::Base
attr_accessor :allowed_user_ids, :tags_changed
DiscourseEvent.on(:site_setting_saved) do |site_setting|
if site_setting.name.to_s == "slug_generation_method" && site_setting.saved_change_to_value?
Scheduler::Defer.later("Null topic slug") do
Topic.update_all(slug: nil)
end
end
end
def self.max_sort_order
@max_sort_order ||= (2**31) - 1
end