This commit is contained in:
albert
2011-07-02 21:04:29 -04:00
parent e9bab19d51
commit bd3af50e10
16 changed files with 94 additions and 32 deletions

View File

@@ -14,7 +14,8 @@ class Note < ActiveRecord::Base
attr_accessible :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :html_id
scope :active, where("is_active = TRUE")
scope :body_matches, lambda {|query| where("text_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))}
search_methods :body_matches
scope :post_tag_match, lambda {|query| joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)}
search_methods :body_matches, :post_tag_match
def presenter
@presenter ||= NotePresenter.new(self)