Newer
Older
# == Schema Information
#
# Table name: communication_website_pages
#
# id :uuid not null, primary key
# about_type :string
# description :text
# path :text
# position :integer default(0), not null
# slug :string
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# about_id :uuid
# communication_website_id :uuid not null
# parent_id :uuid
# university_id :uuid not null
#
# Indexes
#
# index_communication_website_pages_on_about (about_type,about_id)
# index_communication_website_pages_on_category_id (category_id)
# index_communication_website_pages_on_communication_website_id (communication_website_id)
# index_communication_website_pages_on_parent_id (parent_id)
# index_communication_website_pages_on_university_id (university_id)
#
# Foreign Keys
#
# fk_rails_... (category_id => communication_website_categories.id)
# fk_rails_... (communication_website_id => communication_websites.id)
# fk_rails_... (parent_id => communication_website_pages.id)
# fk_rails_... (university_id => universities.id)
#
belongs_to :website,
foreign_key: :communication_website_id
belongs_to :category,
class_name: 'Communication::Website::Category',
optional: true
belongs_to :parent,
class_name: 'Communication::Website::Page',
optional: true
has_many :children,
class_name: 'Communication::Website::Page',
has_one :imported_page,
class_name: 'Communication::Website::Imported::Page',
dependent: :nullify
end
def to_jekyll
ApplicationController.render(
template: 'admin/communication/website/pages/jekyll',
layout: false,
assigns: { page: self }
)
end
self.path = "#{parent&.path}/#{slug}".gsub('//', '/')