From: Toshi MARUYAMA Date: Thu, 22 Sep 2011 00:54:37 +0000 (+0000) Subject: Rails3: model: replace deprecated 'before_save' method at WikiPage model X-Git-Tag: 1.3.0~532 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e16d20f1b47f66e72edaaa6a28d35582876bd73d;p=redmine.git Rails3: model: replace deprecated 'before_save' method at WikiPage model unit wiki_redirect_test.rb has this test. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7438 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 2fe2be53f..27ab4f570 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -44,6 +44,7 @@ class WikiPage < ActiveRecord::Base validate :validate_parent_title before_destroy :remove_redirects + before_save :handle_redirects # eager load information about last updates, without loading text named_scope :with_updated_on, { @@ -70,7 +71,7 @@ class WikiPage < ActiveRecord::Base write_attribute(:title, value) end - def before_save + def handle_redirects self.title = Wiki.titleize(title) # Manage redirects if the title has changed if !@previous_title.blank? && (@previous_title != title) && !new_record?