use simple_form and nested_form
pasted in js from angelxml gem