From 29af9ef16dca042c83141bf8369157c6a0d5b101 Mon Sep 17 00:00:00 2001 From: Coleman Date: Fri, 27 Jun 2008 01:09:29 -0500 Subject: [PATCH] sanitize, not validate --- app/models/page.rb | 5 +++++ 1 file changed, 5 insertions(+) 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