Commit 3ae6d29010f3e11723e830d406e46e0ed11068a7
1 parent
da4b277d
Exists in
theme-brasil-digital-from-staging
and in
9 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
| ... | ... | @@ -18,6 +18,17 @@ class Comment < ActiveRecord::Base |
| 18 | 18 | |
| 19 | 19 | named_scope :without_reply, :conditions => ['reply_of_id IS NULL'] |
| 20 | 20 | |
| 21 | + #FIXME make this test | |
| 22 | + named_scope :newer_than, lambda { |reference_id| | |
| 23 | + {:conditions => ["comments.id > #{reference_id}"]} | |
| 24 | + } | |
| 25 | + | |
| 26 | + #FIXME make this test | |
| 27 | + named_scope :older_than, lambda { |reference_id| | |
| 28 | + {:conditions => ["comments.id < #{reference_id}"]} | |
| 29 | + } | |
| 30 | + | |
| 31 | + | |
| 21 | 32 | # unauthenticated authors: |
| 22 | 33 | validates_presence_of :name, :if => (lambda { |record| !record.email.blank? }) |
| 23 | 34 | validates_presence_of :email, :if => (lambda { |record| !record.name.blank? }) | ... | ... |