Added syntax help to wiki form.
This commit is contained in:
parent
7e4409bc11
commit
0d11e68bad
3 changed files with 19 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue