@@ -43,6 +43,7 class WikiPage < ActiveRecord::Base | |||||
43 | validates_associated :content |
|
43 | validates_associated :content | |
44 |
|
44 | |||
45 | validate :validate_parent_title |
|
45 | validate :validate_parent_title | |
|
46 | before_destroy :remove_redirects | |||
46 |
|
47 | |||
47 | # eager load information about last updates, without loading text |
|
48 | # eager load information about last updates, without loading text | |
48 | named_scope :with_updated_on, { |
|
49 | named_scope :with_updated_on, { | |
@@ -86,7 +87,7 class WikiPage < ActiveRecord::Base | |||||
86 | end |
|
87 | end | |
87 | end |
|
88 | end | |
88 |
|
89 | |||
89 | def before_destroy |
|
90 | def remove_redirects | |
90 | # Remove redirects to this page |
|
91 | # Remove redirects to this page | |
91 | wiki.redirects.find_all_by_redirects_to(title).each(&:destroy) |
|
92 | wiki.redirects.find_all_by_redirects_to(title).each(&:destroy) | |
92 | end |
|
93 | end |
General Comments 0
You need to be logged in to leave comments.
Login now