models: refactor class methods into scopes.
This commit is contained in:
@@ -21,6 +21,8 @@ class WikiPage < ApplicationRecord
|
||||
|
||||
api_attributes including: [:category_name]
|
||||
|
||||
scope :active, -> { where(is_deleted: false) }
|
||||
|
||||
module SearchMethods
|
||||
def find_by_id_or_title(id)
|
||||
if id =~ /\A\d+\z/
|
||||
@@ -34,10 +36,6 @@ class WikiPage < ApplicationRecord
|
||||
where(title: normalize_title(title))
|
||||
end
|
||||
|
||||
def active
|
||||
where("is_deleted = false")
|
||||
end
|
||||
|
||||
def other_names_include(name)
|
||||
name = normalize_other_name(name)
|
||||
subquery = WikiPage.from("unnest(other_names) AS other_name").where_iequals("other_name", name)
|
||||
|
||||
Reference in New Issue
Block a user