Create a new parent on child form?


#1

I’m creating a little event management system and I have an Event
model and an Organization model.

event.rb

belongs_to :organization

organization.rb

has_many :events

When I’m creating a new event, I present a dropdown with already saved
organizations, but I’d like to add a “Create new organization” option
in there and then use Javascript to show the New organization form,
and then have the new event and new organization saved when submitted.

The javascript is not the problem, but figuring out the rest is. I’ve
read over the tutorials where you can do nested models, but those seem
to only work from the parent (i.e. if I were creating a new
organization and wanted to create a bunch of new events at the same
time) rather than vice versa.

Can anyone help me out?