Save the comments to wiki page updates correctly. #415

This commit is contained in:
Felix Schäfer 2011-05-19 22:55:47 +02:00
parent 0957e478ab
commit dbc10d2730
2 changed files with 19 additions and 0 deletions

View File

@ -23,6 +23,10 @@ class WikiContent < ActiveRecord::Base
validates_presence_of :text
validates_length_of :comments, :maximum => 255, :allow_nil => true
attr_accessor :comments
before_save :comments_to_journal_notes
acts_as_journalized :event_type => 'wiki-page',
:event_title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"},
:event_url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}},
@ -67,6 +71,12 @@ class WikiContent < ActiveRecord::Base
last_journal.version
end
private
def comments_to_journal_notes
self.init_journal(author, comments)
end
# FIXME: This is for backwards compatibility only. Remove once we decide it is not needed anymore
WikiContentJournal.class_eval do
attr_protected :data

View File

@ -0,0 +1,9 @@
class RemoveCommentsFromWikiContent < ActiveRecord::Migration
def self.up
remove_column :wiki_contents, :comments
end
def self.down
add_column :wiki_contents, :comments, :string
end
end