allow forum posts to be searched by category (#1720)
This commit is contained in:
@@ -56,6 +56,10 @@ class ForumPost < ActiveRecord::Base
|
||||
q = q.creator_name(params[:creator_name].tr(" ", "_"))
|
||||
end
|
||||
|
||||
if params[:topic_category_id].present?
|
||||
q = q.joins(:topic).where("forum_topics.category_id = ?", params[:topic_category_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
<%= search_field "topic_title_matches", :label => "Title" %>
|
||||
<%= search_field "body_matches", :label => "Body" %>
|
||||
<%= search_field "creator_name", :label => "Author" %>
|
||||
<div class="input">
|
||||
<label for="search_topic_category_id">Category</label>
|
||||
<%= select "search", "topic_category_id", ForumTopic::CATEGORIES.invert.to_a, :include_blank => true %>
|
||||
</div>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user