2005-09-11 16:03:08 +02:00
|
|
|
# This class maintains the state of wiki references for newly created or newly deleted pages
|
|
|
|
class PageObserver < ActiveRecord::Observer
|
|
|
|
|
|
|
|
def after_create(page)
|
|
|
|
WikiReference.update_all("link_type = '#{WikiReference::LINKED_PAGE}'",
|
2005-09-11 18:49:08 +02:00
|
|
|
['referenced_name = ?', page.name])
|
2005-09-11 16:03:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def before_destroy(page)
|
|
|
|
WikiReference.delete_all ['page_id = ?', page.id]
|
|
|
|
WikiReference.update_all("link_type = '#{WikiReference::WANTED_PAGE}'",
|
2005-09-11 18:49:08 +02:00
|
|
|
['referenced_name = ?', page.name])
|
2005-09-11 16:03:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|