blob: 62ac4cb8a9a729659aef87039b960f0c27adf1d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
class Wiki < ActiveRecord::Base
belongs_to :project
belongs_to :user
validates :content, :title, :user_id, :presence => true
validates :title, :length => 1..250
before_update :set_slug
def to_param
slug
end
protected
def set_slug
self.slug = self.title.parameterize
end
class << self
def regenerate_from wiki
regenerated_field = [:slug, :content, :title]
new_wiki = Wiki.new
regenerated_field.each do |field|
new_wiki.send("#{field}=", wiki.send(field))
end
new_wiki
end
end
end
|