foodsoft/app/models/page.rb
Benjamin Meichsner f450070dbf First steps for an own wiki.
* Scaffold for Page Objekt
* Using textile for rendering html
* Easy wiki-links with [[wikipage]]
2009-03-25 19:54:04 +01:00

12 lines
291 B
Ruby

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