# Using date\_select helper without an ActiveRecord model?

**URL:** <https://www.ruby-forum.com/t/using-date-select-helper-without-an-activerecord-model/92898>\
**Category:** Rails\
**Created:** [April 25, 2007, 2:44pm UTC](https://www.ruby-forum.com/t/using-date-select-helper-without-an-activerecord-model/92898 "2007-04-25T14:44:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@martinos](https://www.ruby-forum.com/u/martinos)\
**Post date:** [April 25, 2007, 2:44pm UTC](https://www.ruby-forum.com/t/using-date-select-helper-without-an-activerecord-model/92898/1 "2007-04-25T14:44:55Z")

</div>

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 =  
Date.new(calendar[‘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  
it?
