From 10e03114474b2fb1a04c919596272bd153745341 Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 24 May 2014 12:58:14 -0400 Subject: [PATCH] #2141 normalize other names --- app/models/wiki_page.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 35d853f65..c022d0eed 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -1,5 +1,6 @@ class WikiPage < ActiveRecord::Base before_save :normalize_title + before_save :normalize_other_names before_validation :initialize_creator, :on => :create before_validation :initialize_updater after_save :create_version @@ -135,6 +136,12 @@ class WikiPage < ActiveRecord::Base self.title = title.mb_chars.downcase.tr(" ", "_") end + def normalize_other_names + normalized_other_names = other_names.to_s.gsub(/\u3000/, " ").scan(/\S+/) + normalized_other_names = normalized_other_names.map{|name| name.downcase} + self.other_names = normalized_other_names.uniq.join(" ") + end + def creator_name User.id_to_name(creator_id).tr("_", " ") end