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

@@ -35,15 +35,13 @@ class ForumPost < ApplicationRecord
:body => ->(user_name) {%{@#{creator.name} mentioned you in topic ##{topic_id} ("#{topic.title}":[/forum_topics/#{topic_id}?page=#{forum_topic_page}]):\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n}}
)
scope :active, -> { where(is_deleted: false) }
module SearchMethods
def topic_title_matches(title)
where(topic_id: ForumTopic.search(title_matches: title).select(:id))
end
def active
where("forum_posts.is_deleted = false")
end
def permitted
where(topic_id: ForumTopic.permitted)
end