Model#search: refactor searching for attributes.

This commit is contained in:
evazion
2019-08-29 20:24:52 -05:00
parent 6fc4b63fa8
commit 7b8584e3b0
26 changed files with 90 additions and 212 deletions

View File

@@ -19,10 +19,8 @@ class Note < ApplicationRecord
def search(params)
q = super
q = q.attribute_matches(:body, params[:body_matches], index_column: :body_index)
q = q.attribute_matches(:is_active, params[:is_active])
q = q.search_user_attribute(:creator, params)
q = q.search_post_id_attribute(params)
q = q.search_attributes(params, :creator, :post, :is_active)
q = q.text_attribute_matches(:body, params[:body_matches], index_column: :body_index)
q.apply_default_order(params)
end