Created
January 6, 2011 21:16
-
-
Save charlie/768595 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit aebb80511636cc78f8df6db2c3508ad64ed79cba | |
Author: Charlie <**@**.**> | |
Date: Thu Jan 6 11:16:43 2011 -0800 | |
Guess when the expressions in your named_scopes get evaluated. That's right, bozo, they get evaluated when your classes get loaded :) | |
diff --git a/app/models/offer.rb b/app/models/offer.rb | |
index 410b05a..5e0ce8d 100644 | |
--- a/app/models/offer.rb | |
+++ b/app/models/offer.rb | |
@@ -24,8 +24,8 @@ class Offer < ActiveRecord::Base | |
has_many :facebook_share_stats, :through => :shares, :source => :share_stats, :conditions => ["type = 'FacebookShare'"] | |
has_many :twitter_share_stats, :through => :shares, :source => :share_stats, :conditions => ["type = 'TwitterShare'"] | |
- named_scope :unexpired, :conditions => ["expires_at >= ?", Time.now.utc] | |
- named_scope :live, :conditions => ["(starts_at is null or starts_at <= ?) and expires_at >= ? and published = ?", Time.now.utc, Time.now.utc, true] | |
+ named_scope :unexpired, lambda { {:conditions => ["expires_at >= ?", Time.now.utc]} } | |
+ named_scope :live, lambda { {:conditions => ["(starts_at is null or starts_at <= ?) and expires_at >= ? and published = ?", Time.now.utc, Time.now.utc, true]} } | |
serialized_data :serialized_data, | |
:redeem_instore => :boolean, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment