class Article < ApplicationRecord has_many :all_pages has_many :published_pages validates :name, presence: true, uniqueness: true def all_page_articles AllPage.where('article_id = ? AND type_of = 3 AND published = 1', self.id).order('updated_at DESC') end def published_page_articles PublishedPage.where('article_id = ? AND type_of = 3', self.id).order('created_at DESC') end end