17 lines
498 B
Ruby
17 lines
498 B
Ruby
# 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
|