Date_select and selected options

I can accept the dob date from the _form partial and insert into the DB.
But when I want to display the date as selected in the _form partial,
I’m hitting a wall. Googling hasn;t helped.

_form.rhtml
<%= date_select ‘date’, ‘dob’, :order => [:day,:month,:year],
:start_year => 1930, :include_blank => true%>

##Parameters: {“commit”=>“Create”, “date”=>{“dob(1i)”=>“1938”,
“dob(2i)”=>“5”, “dob(3i)”=>“8”}

logger.debug( params[:date].class ) displays

HashWithIndifferentAccess

accessing no problems

year = params[:date][‘dob(1i)’]
month = params[:date][‘dob(2i)’]
day  = params[:date][‘dob(3i)’]

The two ways I’ve tried to set the selected option with different
results are as follows …

setting selected values

dob = @client.dob.split(/-/)
@date = HashWithIndifferentAccess.new()
@date[‘dob(1i)’] = dob[0]
@date[‘dob(2i)’] = dob[1]
@date[‘dob(3i)’] = dob[2]

error log

ActionView::TemplateError (undefined method `dob’ for {"(3i)"=>“17”,
“year”=>“2008”, “(2i)”=>“6”}:HashWithIndifferentAccess) on line #18 of
app/views/client/_form.rhtml:
15:Â Â
16:Â Â


17:Â Â Â Â DOB
18:Â Â Â Â <%= date_select ‘date’, ‘dob’, :order =>
[:day,:month,:year], :start_year => 1930 %>
19:Â Â
20:Â Â <!–
21:Â Â

… and the other …
_form.rhtml
<%= date_select ‘date’, ‘’, :order => [:day,:month,:year], :start_year
=> 1930, :include_blank => true%>

##Parameters: {“commit”=>“Create”, “date”=>{"(1i)"=>“1938”, “(2i)”=>“5”,
“(3i)”=>“8”}

logger.debug( params[:date].class ) displays

HashWithIndifferentAccess

accessing no problems

year = params[:date][’(1i)’]
month = params[:date][’(2i)’]
day  = params[:date][’(3i)’]

setting selected values

dob = @client.dob.split(/-/)
@date = HashWithIndifferentAccess.new()
@date[’(1i)’] = dob[0]
@date[’(2i)’] = dob[1]
@date[’(3i)’] = dob[2]

error log

ActionView::TemplateError (interning empty string) on line #18 of
app/views/client/_form.rhtml:
15:Â Â


16:Â Â
17:Â Â Â Â DOB
18:Â Â Â Â <%= date_select ‘date’, ‘’, :order => [:day,:month,:year],
:start_year => 1930, :include_blank => true %>
19:Â Â
20:Â Â <!–
21:Â Â

Any pointers from anyone?

CIA

-Ants

Disclaimer: Technically speaking, I am always wrong!

  __________________________________________________________

Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html