summaryrefslogtreecommitdiff
path: root/app/models/wiki.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2012-02-19 19:05:35 +0200
committerValery Sizov <vsv2711@gmail.com>2012-02-19 19:50:13 +0200
commit4c1b8558df1a874716989b8217ab0acf97d6da04 (patch)
treeb9a8beb6e9a2f0f1e50c864b23101c65bd24b527 /app/models/wiki.rb
parenteacea15a2156200fb363508e1bd92fc48226345b (diff)
downloadgitlab-ce-4c1b8558df1a874716989b8217ab0acf97d6da04.tar.gz
Wiki: base implemetation logic
Diffstat (limited to 'app/models/wiki.rb')
-rw-r--r--app/models/wiki.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index 7c50446865e..b1ecc06e132 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -2,10 +2,9 @@ class Wiki < ActiveRecord::Base
belongs_to :project
validates :content, :title, :presence => true
- validates :title, :length => 1..250,
- :uniqueness => {:scope => :project_id, :case_sensitive => false}
+ validates :title, :length => 1..250
- before_save :set_slug
+ before_update :set_slug
def to_param
@@ -17,4 +16,17 @@ class Wiki < ActiveRecord::Base
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