add default scopes to every model

This commit is contained in:
albert
2013-01-07 17:12:43 -05:00
parent 257c0a081e
commit 040059c491
26 changed files with 40 additions and 19 deletions

View File

@@ -16,6 +16,7 @@ class Note < ActiveRecord::Base
scope :body_matches, lambda {|query| where("body_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))}
scope :post_tag_match, lambda {|query| joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)}
search_methods :body_matches, :post_tag_match
default_scope limit(1)
def presenter
@presenter ||= NotePresenter.new(self)