#2141 normalize other names
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
class WikiPage < ActiveRecord::Base
|
class WikiPage < ActiveRecord::Base
|
||||||
before_save :normalize_title
|
before_save :normalize_title
|
||||||
|
before_save :normalize_other_names
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
before_validation :initialize_updater
|
before_validation :initialize_updater
|
||||||
after_save :create_version
|
after_save :create_version
|
||||||
@@ -135,6 +136,12 @@ class WikiPage < ActiveRecord::Base
|
|||||||
self.title = title.mb_chars.downcase.tr(" ", "_")
|
self.title = title.mb_chars.downcase.tr(" ", "_")
|
||||||
end
|
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
|
def creator_name
|
||||||
User.id_to_name(creator_id).tr("_", " ")
|
User.id_to_name(creator_id).tr("_", " ")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user