Forum: Ruby on Rails using date_select helper without an ActiveRecord model?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D05ccb32ba0f2a5115b18a5729cd9379?d=identicon&s=25 Martin Maciaszek (Guest)
on 2007-04-25 14:44
(Received via mailing list)
I would like to use a date_select helper to select a date that will be
used as a part of a condition in an ActiveRecord::find. The code I'm
using looks like this:

<%= date_select :calendar, :show_month, :order => [:month, :year] %>

How do I get a Date object from the params submitted? I ended up with
code that looks like this:

calendar = params[:calendar]
my_date =['show_month(1i)'].to_i,calendar['show_month(2i)'].to_i,calendar['show_month(3i)'].to_i)

This looks pretty ughly. There has to be a simpler and cleaner way to
do this.

On the other hand I want the date_select helper to have a certain date
preselected. Not having an ActiveRecord object how does the object
need to look like so date_select will be able to extract the date from
This topic is locked and can not be replied to.