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: </tr>
16: <tr>
17: <th>DOB</th>
18: <td><%= date_select ''date'',
''dob'', :order => [:day,:month,:year], :start_year =>
1930 %></td>
19: </tr>
20: <!--
21: <tr>
..... 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: </tr>
16: <tr>
17: <th>DOB</th>
18: <td><%= date_select ''date'',
'''', :order => [:day,:month,:year], :start_year => 1930,
:include_blank => true %></td>
19: </tr>
20: <!--
21: <tr>
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---