Hey, how do I set a scope in rails 3 to todays records?
This doent work, yet. I get no data.
class MyModel < ActiveRecord::Base
scope :today, :con
Rails evaluates the scope at the class level so when you use :conditions => { :created_at => Date.today } it evaluates Date.today and compare all records with pre evaluated date. To avoid this use lamda to define date or time specific scopes
scope :today, lambda { :conditions =>[ "created_at = ? ", Date.today] }