app/models/wiki.rb
# == Schema Information
#
# Table name: pages
#
# id :integer not null, primary key
# title :string(255) not null
# content :text(16777215)
# slug :string(255) not null
# ancestry :string(255)
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# secret :boolean default(TRUE), not null
#
# Indexes
#
# index_pages_on_ancestry (ancestry)
# index_pages_on_slug (slug) UNIQUE
# index_pages_on_user_id (user_id)
#
class Wiki < Page
default_scope -> { roots }
def pages
descendants
end
def attachments
Attachment.where(page_id: subtree_ids)
end
def activities
PaperTrail::Version.where(item_id: descendant_ids)
end
end