Commit 36c88d59ee8398c4b28ab839f386860b92938a1f
Committed by
Rodrigo Souto
1 parent
defa79af
Exists in
api_tasks
and in
4 other branches
adding newer_than older_than named scope methods
Showing
1 changed file
with
11 additions
and
0 deletions
Show diff stats
app/models/comment.rb
... | ... | @@ -20,6 +20,17 @@ class Comment < ActiveRecord::Base |
20 | 20 | |
21 | 21 | scope :without_reply, :conditions => ['reply_of_id IS NULL'] |
22 | 22 | |
23 | + #FIXME make this test | |
24 | + named_scope :newer_than, lambda { |reference_id| | |
25 | + {:conditions => ["comments.id > #{reference_id}"]} | |
26 | + } | |
27 | + | |
28 | + #FIXME make this test | |
29 | + named_scope :older_than, lambda { |reference_id| | |
30 | + {:conditions => ["comments.id < #{reference_id}"]} | |
31 | + } | |
32 | + | |
33 | + | |
23 | 34 | # unauthenticated authors: |
24 | 35 | validates_presence_of :name, :if => (lambda { |record| !record.email.blank? }) |
25 | 36 | validates_presence_of :email, :if => (lambda { |record| !record.name.blank? }) | ... | ... |