Hi, this is probably simple, but I’m just starting to learn…
I have an action that displays a paginated list of events in one table
of my database. I want it to display all of the events from today’s date
and onward (exclude past events, basically). This is as far as I’ve
gotten:
def list
@show_pages, @shows = paginate(:shows, :per_page => 15, :conditions
=> [‘shows.date_time >= ?’, ‘2007-01-08 22:01:00’ ], :order => %w(
shows.date_time ))
end
Putting today’s date/time in the database query is where I’m stuck. I
manually entered the date/time you see above and it works perfectly.
What do I need to do to include a dynamically generated date/time?
Thanks in advance!
Grant B. wrote:
I have an action that displays a paginated list of events in one table
of my database. I want it to display all of the events from today’s date
and onward (exclude past events, basically). This is as far as I’ve
gotten:
def list
@show_pages, @shows = paginate(:shows, :per_page => 15, :conditions
=> [‘shows.date_time >= ?’, ‘2007-01-08 22:01:00’ ], :order => %w(
shows.date_time ))
end
Putting today’s date/time in the database query is where I’m stuck. I
manually entered the date/time you see above and it works perfectly.
Nevermind, I figured it out - placing Time.now without quotes did the
trick - I think I had originally been trying Date.now and getting now
results because time wasn’t included…
Here’s the working code:
def list
@show_pages, @shows = paginate(:shows, :per_page => 15,
:conditions => [‘shows.date_time >= ?’, Time.now ], :order => %w(
shows.date_time ))
end