So we can get started with nested form now, we can imagine that we have a Product model that has_many :photos.
To be able to use this function, you need to add some configuration to your Product model, ad we have Photo model
which is to store the photos.
If you don't have the accepts_nested_attributes_for settings for photos, you'll get a Missing Block Error.
We also use SimpleForm to make our form simpler, in this Git repo, It was implemented to use simple_nested_form_for for SimpleForm support. But this feature is not yet in a Gem release, so you can use this git repo.
Here is the form.
=simple_nested_form_forresource,:url=>products_pathdo|f|=f.input:name-resource.photos.eachdo|photo|=f.simple_fields_for:photos,photodo|p|.photo=label_tag''=image_tagphoto.data%br/=label_tag''=p.link_to_remove'delete this image'=p.input:data_cache,:as=>:hidden=f.simple_fields_for:photos,resource.photos.builddo|p|=p.input:data,:as=>:file=p.input:data_cache,:as=>:hidden=p.link_to_remove'remove'=f.link_to_add'Add',:photos.actions=f.submit'Save changes'=button_tag'Reset',:type=>'reset'