ryanb wrote:Are you getting this error on the initial form page or only after submitting the form?
It was on the initial form page. However, I changed up a few things (trial and error) and now I don't have that issue. I'm instead (of course) having another problem building the object arrays from the form in the controller. It all stems from how the naming in my fields_for tag is. To me, nothing seems clear on this.
So if I have a field tag that looks like this:
<% fields_for
"resume.education_histories[#{index}][address]",
@resume.education_histories[index].address do |@address_fields| %>
I get an address input tag like so:
<input id="resume.education_histories[0][address]_street_1"
name="resume.education_histories[0][address][street_1]" size="30" type="text" />
But, if I look how the form params were submitted, I don't get the proper object graph set up and instead have params like this for the resume histories (dunno why the left '[' char gets dropped):
resume.education_histories"=>
{"0].[end_date(2i)"=>"6", "0].[degree_level"=>"-- Please select --", "0].[key_achievements"=>"",
"0].[end_date(3i)"=>"19",
"0].[start_date(1i)"=>"2007", "0].[start_date(2i)"=>"6",
"0].[start_date(3i)"=>"19", "0"=>{"address"=>{"city"=>"", "zip"=>"",
"street_1"=>"", "country"=>"United States", "street_2"=>"", "state"=>""}}
and params like this for the parent resume object:
"resume"=>
{"dreamjob_status"=>"Full time", "dreamjob_description"=>"",
"dreamjob_title"=>"", "html_resume_link"=>"", "title"=>""}
Clearly, the education_histories should be nested properly in the resume object *and* the address should be nested properly in each education_histories obj.
The error Rails comes back with is
You have a nil object when you didn't expect it!
The error occured while evaluating nil.each_value
I've been playing around with different fields_for names with no luck yet.