post replacements: add tag match field to search form.

This commit is contained in:
evazion
2017-06-22 16:50:25 -05:00
parent 8b4e598a12
commit 6329d089ee
2 changed files with 9 additions and 0 deletions

View File

@@ -69,6 +69,10 @@ class PostReplacement < ApplicationRecord
end
module SearchMethods
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post))
end
def search(params = {})
q = all
@@ -88,6 +92,10 @@ class PostReplacement < ApplicationRecord
q = q.where(post_id: params[:post_id].split(",").map(&:to_i))
end
if params[:post_tags_match].present?
q = q.post_tags_match(params[:post_tags_match])
end
q = q.order("created_at DESC")
q

View File

@@ -6,6 +6,7 @@
<%= simple_form_for(:search, url: post_replacements_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
<%= f.input :creator_name, label: "Replacer", input_html: { value: params[:search][:creator_name] } %>
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
<%= f.submit "Search" %>
<% end %>