Commit 1fc0ff85c48fbb6d0654898db1957d284678cfd4
Committed by
Rodrigo Souto
1 parent
f05fef14
Exists in
staging
and in
41 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,6 +20,17 @@ class Comment < ActiveRecord::Base | ||
| 20 | 20 | ||
| 21 | scope :without_reply, :conditions => ['reply_of_id IS NULL'] | 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 | # unauthenticated authors: | 34 | # unauthenticated authors: |
| 24 | validates_presence_of :name, :if => (lambda { |record| !record.email.blank? }) | 35 | validates_presence_of :name, :if => (lambda { |record| !record.email.blank? }) |
| 25 | validates_presence_of :email, :if => (lambda { |record| !record.name.blank? }) | 36 | validates_presence_of :email, :if => (lambda { |record| !record.name.blank? }) |