Added syntax help to wiki form.

This commit is contained in:
Benjamin Meichsner 2009-05-13 17:32:43 +02:00
parent 7e4409bc11
commit 0d11e68bad
3 changed files with 19 additions and 3 deletions

View file

@ -1,11 +1,12 @@
class Page < ActiveRecord::Base
validates_presence_of :title, :body
validates_uniqueness_of :permalink
before_save :set_permalink
before_validation_on_create :set_permalink
def set_permalink
if self.permalink.blank? #FIXME: or title.changed?
if self.permalink.blank?
self.permalink = Page.count == 0 ? "home" : "#{title.downcase.strip.gsub(/ |\.|@/, '-')}"
end
end