allow forum posts to be searched by category (#1720)

This commit is contained in:
Toks
2013-06-13 23:07:19 -04:00
parent f653ea68ca
commit 05be9f41e7
2 changed files with 8 additions and 0 deletions

View File

@@ -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

View File

@@ -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>