gregbell/active_admin — pull request #2682 by sharshenov (2013-11-09 06:53:58+00:00)
Title: Fix wrong fieldset detection for a nested form fields

Hi. Here is small patch to fix wrong fieldset count detection for a nested form fields.
Here are steps to reproduce current bug(still exists):
1. Create active admin resource for a model with has_many relation
2. Add nested form fields.

form do |f|
f.inputs "Car Details" do
f.input :automaker
f.input :title
f.inputs do
f.has_many :tags, heading: 'Tags', allow_destroy: true do |t|
t.input :title
end
end
end
f.actions
end

3. Create a new record with some nested records with active admin. (A car with some tags in my case)
4. Go to edit page for this record
5. Click 'Add New Tag' button. It will create new fieldset with wrong NEW_TAG_RECORD (equals 0)
6. Click 'Save'
7. Created nested record _replaces_ first one.