feat: Portal and Category public APIs (#4946)

This commit is contained in:
Tejaswini Chile
2022-07-05 17:15:38 +05:30
committed by GitHub
parent ae59d0a343
commit 029209a634
18 changed files with 154 additions and 9 deletions

View File

@@ -53,7 +53,7 @@ class Article < ApplicationRecord
validates :title, presence: true
validates :content, presence: true
enum status: { draft: 0, published: 1 }
enum status: { draft: 0, published: 1, archived: 2 }
scope :search_by_category_slug, ->(category_slug) { where(categories: { slug: category_slug }) if category_slug.present? }
scope :search_by_category_locale, ->(locale) { where(categories: { locale: locale }) if locale.present? }
@@ -100,6 +100,10 @@ class Article < ApplicationRecord
article.associated_article_id || article.id
end
def draft!
update(status: :draft)
end
private
def ensure_account_id