I have models A and B. A has_many B. In the edit view for A I am
displaying all of it’s B children using
f.inputs :for => :bs do |b|...
What I want to do is add a ‘delete’ link or button after ever
B child of A. At the end of the list of B’s I’d like to add a ‘Add B’
button which would create a new B instance and associate it with the
current A. This way I can avoid an additional edit view for B (B is a
very simple model).
I figured it out. I had to create a custom form partial. You do this by creating a file called ‘app/views/admin/_as.html.erb’. Here you can create you form like you would a normal view, starting with:
Then in ‘app/admin/as.rb’ you just need to add the line:
In this contrived example ‘a’ is my A class so replace it where necessary.