From 36c88d59ee8398c4b28ab839f386860b92938a1f Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Thu, 17 Apr 2014 14:52:10 -0300 Subject: [PATCH] adding newer_than older_than named scope methods --- app/models/comment.rb | 11 +++++++++++ 1 file changed, 11 insertions(+), 0 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index d9d2e65..f9f747c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -20,6 +20,17 @@ class Comment < ActiveRecord::Base scope :without_reply, :conditions => ['reply_of_id IS NULL'] + #FIXME make this test + named_scope :newer_than, lambda { |reference_id| + {:conditions => ["comments.id > #{reference_id}"]} + } + + #FIXME make this test + named_scope :older_than, lambda { |reference_id| + {:conditions => ["comments.id < #{reference_id}"]} + } + + # unauthenticated authors: validates_presence_of :name, :if => (lambda { |record| !record.email.blank? }) validates_presence_of :email, :if => (lambda { |record| !record.name.blank? }) -- libgit2 0.21.2