This commit is contained in:
albert
2012-02-20 14:35:22 -05:00
parent 3eb06a43c4
commit e745c30699
2 changed files with 3 additions and 2 deletions

View File

@@ -15,8 +15,9 @@ class Comment < ActiveRecord::Base
scope :visible, lambda {|user| where("score >= ?", user.comment_threshold)}
scope :post_tag_match, lambda {|query| joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)}
scope :for_user, lambda {|user_id| where("creator_id = ?", user_id)}
scope :for_user_name, lambda {|user_name| where("creator_id = (select _.id from users _ where lower(_.name) = lower(?))", user_name)}
search_methods :body_matches, :post_tag_match
search_methods :body_matches, :post_tag_match, :for_user_name
def initialize_creator
self.creator_id = CurrentUser.user.id

View File

@@ -5,7 +5,7 @@
<%= simple_form_for(@search) do |f| %>
<%= hidden_field_tag "group_by", "comment" %>
<%= f.input :body_matches, :label => "Body", :required => false %>
<%= f.input :creator_name_equals, :label => "User", :required => false %>
<%= f.input :for_user_name, :label => "User", :required => false %>
<%= f.input :post_tag_match, :label => "Tags", :required => false %>
<%= f.button :submit, "Search" %>