Newer
Older
# == Schema Information
#
# Table name: communication_website_posts
#
# id :uuid not null, primary key
# description :text
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# communication_website_id :uuid not null
# university_id :uuid not null
#
# Indexes
#
# index_communication_website_posts_on_author_id (author_id)
# index_communication_website_posts_on_communication_website_id (communication_website_id)
# index_communication_website_posts_on_university_id (university_id)
#
# Foreign Keys
#
# fk_rails_... (author_id => communication_website_authors.id)
# fk_rails_... (communication_website_id => communication_websites.id)
# fk_rails_... (university_id => universities.id)
#
class Communication::Website::Post < ApplicationRecord
belongs_to :university
belongs_to :website,
foreign_key: :communication_website_id
belongs_to :author,
class_name: 'Communication::Website::Author',
optional: true
has_and_belongs_to_many :categories,
class_name: 'Communication::Website::Category',
join_table: 'communication_website_categories_posts',
foreign_key: 'communication_website_post_id',
association_foreign_key: 'communication_website_category_id'
scope :ordered, -> { order(published_at: :desc, created_at: :desc) }
scope :recent, -> { order(published_at: :desc).limit(5) }
"_posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html"
ApplicationController.render(
template: 'admin/communication/website/posts/jekyll',
layout: false,
assigns: { post: self }
)