Nested forms, extreme weirdness


#1

I took a look at nested forms a few weeks ago, played with it a bit and
it all seemed fine. Now I need to actually use it and it’s blown up in
my face.

I’ve got in my account.rb

has_many :subscriptions

and
accepts_nested_attributes_for :subscriptions

then in my view

<% form_for @account do |form| %>
etc
<% form.fields_for :subscriptions do |subscription_form| -%>
etc
<% end %>
<% end %>

Now here’s the really really weird thing; the nested form should be
produced and it isn’t, but if I change the name from :subscriptions to
anything else, then the form is produced, but of course with wrong names
on the input fields.

Wtf am I doing wrong?

John S.


#2

Ha! Solved it

I had to create at least one instance of a subscription for an account
before the form would be displayed.

Why it would display the form for symbols other than :subscriptions is
another mystery, which I don’t need to worry about.

John S.