]> source.dussan.org Git - redmine.git/commitdiff
Rails3: model: replace deprecated 'before_destroy' method at WikiPage model
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 22 Sep 2011 00:53:53 +0000 (00:53 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 22 Sep 2011 00:53:53 +0000 (00:53 +0000)
test_redirects_removed_when_deleting_page at unit wiki_redirect_test.rb has this test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7437 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/wiki_page.rb

index 4c2c7adb9189445f6f4dfb4e1702535736cba1c4..2fe2be53f4775a0bbd98fdb4aa8ca4904c8e47a6 100644 (file)
@@ -43,6 +43,7 @@ class WikiPage < ActiveRecord::Base
   validates_associated :content
 
   validate :validate_parent_title
+  before_destroy :remove_redirects
 
   # eager load information about last updates, without loading text
   named_scope :with_updated_on, {
@@ -86,7 +87,7 @@ class WikiPage < ActiveRecord::Base
     end
   end
 
-  def before_destroy
+  def remove_redirects
     # Remove redirects to this page
     wiki.redirects.find_all_by_redirects_to(title).each(&:destroy)
   end