# Beyond frusterating date\_select issue

**URL:** <https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740>\
**Category:** Rails\
**Created:** [November 6, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740 "2008-11-06T23:52:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 6, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740/1 "2008-11-06T23:52:24Z")

</div>

I have this code: \<%= date\_select(“post”, “from”) %\>

simple, easy, works! The problem comes when I need to build a query  
around these dates. In my log I see that the params are being passed  
like this:

“post”=\>{“from(1i)”=\>“2008”, “to(1i)”=\>“2008”, “from(2i)”=\>“11”,  
“to(2i)”=\>“11”, “from(3i)”=\>“6”, “to(3i)”=\>“6”}

When I try and access the params, such as, by saying: params[:to][:3i],  
ruby barks at me. All other variations have failed to get at the values.  
So, my question is this: how in the name of everything holy am I  
supposed to get the month, day, and year from the params hash when  
hashes containing integers - 1, 2, 3, etc. - are inaccessable via ruby.  
I have tried putting the values into a date object and everythign simply  
does not work or come out as nil. Has anyone had any success at getting  
at those values? Thanks,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 7, 2008, 12:04am UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740/2 "2008-11-07T00:04:01Z")

</div>

> 3i],  
> at those values? Thanks,  
> Maybe I’m not understanding but why not access params[:post][:from]  
> and then request what parts you want using DateTime methods.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 7, 2008, 12:11am UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740/3 "2008-11-07T00:11:04Z")

</div>

Philip H. wrote:

> > 3i],  
> > at those values? Thanks,  
> > Maybe I’m not understanding but why not access params[:post][:from]  
> > and then request what parts you want using DateTime methods.

it doesn’t complain when I do that but it doesn’t give any values back  
either. If I try params[:to][:1i] it complains about the number, if I  
try params[:to][“1i”] I get

You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]

Parameters:

{“commit”=\>“Submit”,  
“post”=\>{“from(1i)”=\>“2008”,  
“to(1i)”=\>“2008”,  
“from(2i)”=\>“11”,  
“to(2i)”=\>“11”,  
“from(3i)”=\>“6”,  
“to(3i)”=\>“6”}}

Right now I am lost on what to do because this should be simple.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 7, 2008, 12:55am UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740/4 "2008-11-07T00:55:30Z")

</div>

On Nov 6, 11:11 pm, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Philip H. wrote:
> 
> > > 3i],  
> > > at those values? Thanks,  
> > > Maybe I’m not understanding but why not access params[:post][:from]  
> > > and then request what parts you want using DateTime methods.
> 
> it doesn’t complain when I do that but it doesn’t give any values back  
> either. If I try params[:to][:1i] it complains about the number, if I  
> try params[:to][“1i”] I get

Your’re trying too hard. params[‘post’][‘to(1i)’] etc… (or use  
select\_date )

Fred

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [January 8, 2009, 8:05am UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740/5 "2009-01-08T08:05:55Z")

</div>

suppose to be its params[:to]["(1i)"]

not

params[:to][“1i”]

On Nov 7 2008, 7:11 am, Shandy N. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 7, 2008, 12:21am UTC](https://www.ruby-forum.com/t/beyond-frusterating-date-select-issue/152740/6 "2008-11-07T00:21:35Z")

</div>

This may just be superstition talking, but I wonder if the problem is  
the names “from” and “to”. Any difference if you make those, e.g.,  
“from\_date” and “to\_date”?
