models: refactor class methods into scopes.

This commit is contained in:
evazion
2020-02-17 02:10:08 -06:00
parent 9a8aa1990d
commit 83a0cb0a71
12 changed files with 45 additions and 126 deletions

View File

@@ -24,15 +24,10 @@ class Comment < ApplicationRecord
:body => ->(user_name) {"@#{creator.name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n"}
)
scope :deleted, -> { where(is_deleted: true) }
scope :undeleted, -> { where(is_deleted: false) }
module SearchMethods
def deleted
where("comments.is_deleted = true")
end
def undeleted
where("comments.is_deleted = false")
end
def search(params)
q = super