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

@@ -44,13 +44,8 @@ class UserFeedback < ApplicationRecord
def search(params)
q = super
q = q.attribute_matches(:body, params[:body_matches])
q = q.search_user_attribute(:user, params)
q = q.search_user_attribute(:creator, params)
if params[:category].present?
q = q.where("category = ?", params[:category])
end
q = q.search_attributes(params, :user, :creator, :category)
q = q.text_attribute_matches(:body, params[:body_matches])
q.apply_default_order(params)
end