pdfshop/app/models/article.rb

27 lines
696 B
Ruby

# == Schema Information
#
# Table name: articles
#
# id :integer not null, primary key
# name :string(255) not null
# updated_at :datetime
# updated_by :bigint(8)
#
# Articles for page
class Article < ApplicationRecord
has_many :all_pages, dependent: :destroy
has_many :published_pages, dependent: :destroy
validates :name, presence: true, uniqueness: true
def all_page_articles
AllPage.where('article_id = ? AND type_of = 3 AND published = 1',
id).order('updated_at DESC')
end
def published_page_articles
PublishedPage.where('article_id = ? AND type_of = 3',
id).order('created_at DESC')
end
end