Re: date_select oddness

Tomasz Bąk
Wed, 30 Nov 2005 08:30:12 -0000

jonathan <zjll9-qOlZ2LGq26weF4Ui59n7hQ@public.gmane.org>
napisał(a):
> openbsdpl wrote:
>
>>Hello,
>>I have a problem when with this tag in view:
>>   <%= date_select :customdate, nil %>
>>
>>In the controller there is:
>>   d = Date.new
>>   d = params[:customdate]
>>   render_text "#{d.inspect}"
>>
>>The problem is the :customdate doesnt get transformed
>>into Date, instead I get this:
>>   {"(3i)"=>"29",
"(1i)"=>"2005", "(2i)"=>"11"}
>>
>
>
> Shouldn''t it be:
>
> d = Date.new( params[:customdate] )
>
> ??
Nope. This throws an error:
NoMethodError in Forms#korpus_create_row

undefined method `-'' for {"(3i)"=>"30",
"(1i)"=>"2005",
"(2i)"=>"11"}:HashWithIndifferentAccess

c:/ruby/lib/ruby/1.8/date.rb:297:in `civil_to_jd''
c:/ruby/lib/ruby/1.8/date.rb:568:in `valid_civil?''
c:/ruby/lib/ruby/1.8/date.rb:590:in `new''
#{RAILS_ROOT}/app/controllers/forms_controller.rb:279:in
`korpus_create_row''