Nested forms, extreme weirdness


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

accepts_nested_attributes_for :subscriptions

then in my view

<% form_for @account do |form| %>
<% form.fields_for :subscriptions do |subscription_form| -%>
<% 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.


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.