Re: Help with nested models and fields_for

Marnen Laibow-Koser
Mon, 22 Dec 2008 21:02:35 -0000

On Dec 22, 1:22 am, Mark Reginald James
<m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org>
wrote:
> The test I did was to post from the following view.
>
>
> <input name="recipe[ingredient_lines][][ingredient][name]"
type="text"/>
>
>
> On Rails >= 2.1 I got the correct
>
"recipe"=>{"ingredient_lines"=>[{"ingredient"=>{"name"=>"hhh"}}]}
>
> on 2.0.2 I got what you''re seeing:
>
"recipe"=>{"ingredient_lines"=>[{"ingredient"=>{}}]}
>
> You may like to run the same test.

Thanks for the suggestion.  I tried the same test, and got interesting
if disheartening results.  When I had recipe[ingredient_lines][]
[ingredient][name] as the only form field, I got the same results as
you.  But the moment I added recipe[ingredient_lines][][unit],
[ingredient][name] stopped working.  This was true both with Rails
2.1.2 and 2.2.2.  I think I may be running into a bug in Rails.

Best,
--
Marnen Laibow-Koser
marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
http://www.marnen.org
>
> If you see the same, perhaps the problem manifests when extra
> parameters are added. You can try adding fields until you
> are posting your complete form.  Please post what you find out.
>
> --
> Rails Wheels - Find Plugins, List & Sell Plugins
-http://railswheels.com