start changing param parsing to allow and and or of tags

This commit is contained in:
Reinier Balt 2011-10-01 03:45:41 +02:00
parent 34a005ec0e
commit 2accbd0a32
3 changed files with 117 additions and 9 deletions

View file

@ -39,6 +39,7 @@ class Todo < ActiveRecord::Base
# other scopes
named_scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
named_scope :with_tag, lambda { |tag| {:joins => :taggings, :conditions => ["taggings.tag_id = ? ", tag.id] } }
named_scope :with_tags, lambda { |tag_ids| {:joins => :taggings, :conditions => ["taggings.tag_id IN (?) ", tag_ids] } }
named_scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
named_scope :completed_after, lambda { |date| {:conditions => ["todos.completed_at > ? ", date] } }
named_scope :completed_before, lambda { |date| {:conditions => ["todos.completed_at < ? ", date] } }