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!