I’m trying to get all records which have a datetime field (not created at) in a given month
Eg
month = 1
@events_this_month = Events.find :all, :conditions => {:date.month => month}
Obviously not the way to do it (symbol isn’t a date object!) but I hope it gives you an idea of what I’m hoping for!
I created a gem just for this reason called by_star, You can find events for a given month using this syntax:
That code would get you all the events for the 2nd month of the yeah. It also does month names and takes Date and Time objects.
Should be perfect for your needs.
A little additional tip: your model classes should be singularized. That’s the convention in Rails.