I would like to use an instruction like ...
current_user.workouts.find_by_created_at(Time.now.day)
but this does not work, I suppose, because times do not coincide. I will continue to read documents, but I thought I would post this question to ask for help while I read.
Thanks!
UPDATE Using the new Rails 3 support for AREL and named areas, I reorganized the request to ...
Model
class Workout < ActiveRecord::Base scope :from_today, where(" created_at between ? AND ?", Time.zone.now.beginning_of_day, Time.zone.now.end_of_day) . . . end
controller
def create workouts = current_user.workouts.from_today . . . end
source share