Rails - Trying to query from a date range...everything from today
- by ChrisWesAllen
I'm trying to figure the best way to query a date range from rails...I looked around on Google but am unsure about how to use this syntax.
I have a Model that has various events and I like to add to my find condition a caveat that should only show events where the field :st_date is today or later, in effect only show me data that is current, nothing that happened before today.
I ran into a problem because I have no end date to stop the query, I want to query everything from today to next month.
I was thinking something like
@events = Event.find(:all, :conditions => ["start_date between ? and ?",
date.Today, date.next_month.beginning_of_month])
but I get the error undefined local variable or method `date'......
Do I need do anything particular to use the Date class? Or is there something wrong with my query syntax? I would really appreciate any help.