Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

app code in general wants Time.current, not Time.now

  • Loading branch information...
commit 7a80ac0162ae84cf22c91646690ad18916a66274 1 parent bbafe73
@fxn fxn authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/scoping/named.rb
View
6 activerecord/lib/active_record/scoping/named.rb
@@ -118,16 +118,16 @@ def scope_attributes? # :nodoc:
# 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 <tt>Time.now</tt> value when the <tt>Post</tt>
+ # The example above would be 'frozen' to the <tt>Time.current</tt> value when the <tt>Post</tt>
# 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 <tt>has_many</tt> declarations:
Please sign in to comment.
Something went wrong with that request. Please try again.