diff --git a/app/models/page.rb b/app/models/page.rb index f1fe242..23be1c7 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -11,6 +11,7 @@ class Page < ActiveRecord::Base has_and_belongs_to_many :pages_that_link_to_me, :join_table => 'wiki_words', :foreign_key => :destination_id, :association_foreign_key => :source_id, :class_name => 'Page' before_create :set_author_id + before_save :sanitize_department after_save :update_wiki_words after_save :destroy_cache @@ -50,6 +51,10 @@ class Page < ActiveRecord::Base protected + def sanitize_department + self.department.gsub!(/[^\w']/, '_').gsub!(/__+/, '_') + end + def set_author_id self.author_id ||= Application.current_author_id end