From e99987bc309a276bb6aea700ff184194768a6ee4 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 28 Dec 2011 23:47:10 +0100 Subject: app code in general wants Time.current, not Time.now --- activerecord/lib/active_record/scoping/named.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/scoping') diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb index 17122740da..0edc3f1dcc 100644 --- a/activerecord/lib/active_record/scoping/named.rb +++ b/activerecord/lib/active_record/scoping/named.rb @@ -118,16 +118,16 @@ module ActiveRecord # when they are used. For example, the following would be incorrect: # # class Post < ActiveRecord::Base - # scope :recent, where('published_at >= ?', Time.now - 1.week) + # scope :recent, where('published_at >= ?', Time.current - 1.week) # end # - # The example above would be 'frozen' to the Time.now value when the Post + # The example above would be 'frozen' to the Time.current value when the Post # class was defined, and so the resultant SQL query would always be the same. The correct # way to do this would be via a lambda, which will re-evaluate the scope each time # it is called: # # class Post < ActiveRecord::Base - # scope :recent, lambda { where('published_at >= ?', Time.now - 1.week) } + # scope :recent, lambda { where('published_at >= ?', Time.current - 1.week) } # end # # Named \scopes can also have extensions, just as with has_many declarations: -- cgit v1.2.3