sanitize, not validate

master
Coleman 2008-06-27 01:09:29 -05:00
parent 005fac8bca
commit 29af9ef16d
1 changed files with 5 additions and 0 deletions

View File

@ -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' 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_create :set_author_id
before_save :sanitize_department
after_save :update_wiki_words after_save :update_wiki_words
after_save :destroy_cache after_save :destroy_cache
@ -50,6 +51,10 @@ class Page < ActiveRecord::Base
protected protected
def sanitize_department
self.department.gsub!(/[^\w']/, '_').gsub!(/__+/, '_')
end
def set_author_id def set_author_id
self.author_id ||= Application.current_author_id self.author_id ||= Application.current_author_id
end end