@@ -44,6 +44,7 class WikiPage < ActiveRecord::Base | |||||
44 |
|
44 | |||
45 | validate :validate_parent_title |
|
45 | validate :validate_parent_title | |
46 | before_destroy :remove_redirects |
|
46 | before_destroy :remove_redirects | |
|
47 | before_save :handle_redirects | |||
47 |
|
48 | |||
48 | # eager load information about last updates, without loading text |
|
49 | # eager load information about last updates, without loading text | |
49 | named_scope :with_updated_on, { |
|
50 | named_scope :with_updated_on, { | |
@@ -70,7 +71,7 class WikiPage < ActiveRecord::Base | |||||
70 | write_attribute(:title, value) |
|
71 | write_attribute(:title, value) | |
71 | end |
|
72 | end | |
72 |
|
73 | |||
73 | def before_save |
|
74 | def handle_redirects | |
74 | self.title = Wiki.titleize(title) |
|
75 | self.title = Wiki.titleize(title) | |
75 | # Manage redirects if the title has changed |
|
76 | # Manage redirects if the title has changed | |
76 | if !@previous_title.blank? && (@previous_title != title) && !new_record? |
|
77 | if !@previous_title.blank? && (@previous_title != title) && !new_record? |
General Comments 0
You need to be logged in to leave comments.
Login now