Refactor scopes on site customization page model
This commit is contained in:
@@ -13,11 +13,12 @@ class SiteCustomization::Page < ActiveRecord::Base
|
||||
format: { with: /\A[0-9a-zA-Z\-_]*\Z/, message: :slug_format }
|
||||
validates :status, presence: true, inclusion: { in: VALID_STATUSES }
|
||||
|
||||
scope :published, -> { where(status: "published").order("id DESC") }
|
||||
scope :with_more_info_flag, -> { where(status: "published",
|
||||
more_info_flag: true).order("id ASC") }
|
||||
scope :with_same_locale, -> { joins(:translations)
|
||||
.where("site_customization_page_translations.locale": I18n.locale) }
|
||||
scope :published, -> { where(status: "published").sort_desc }
|
||||
scope :sort_asc, -> { order("id ASC") }
|
||||
scope :sort_desc, -> { order("id DESC") }
|
||||
scope :with_more_info_flag, -> { where(status: "published", more_info_flag: true).sort_asc }
|
||||
scope :with_same_locale, -> { joins(:translations).locale }
|
||||
scope :locale, -> { where("site_customization_page_translations.locale": I18n.locale) }
|
||||
|
||||
def url
|
||||
"/#{slug}"
|
||||
|
||||
Reference in New Issue
Block a user