Add additional search options
This commit is contained in:
@@ -2,9 +2,23 @@ class ArtistCommentaryVersion < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to_updater
|
||||
|
||||
def self.text_matches(query)
|
||||
query = "*#{query}*" unless query =~ /\*/
|
||||
|
||||
where_ilike(:original_title, query)
|
||||
.or(where_ilike(:original_description, query))
|
||||
.or(where_ilike(:translated_title, query))
|
||||
.or(where_ilike(:translated_description, query))
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
q = q.search_attributes(params, :original_title, :original_description, :translated_title, :translated_description)
|
||||
|
||||
if params[:text_matches].present?
|
||||
q = q.text_matches(params[:text_matches])
|
||||
end
|
||||
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user