diff --git a/lib/generators/nested_form/templates/jquery_nested_form.js b/lib/generators/nested_form/templates/jquery_nested_form.js index 669fabf9..c893a73b 100644 --- a/lib/generators/nested_form/templates/jquery_nested_form.js +++ b/lib/generators/nested_form/templates/jquery_nested_form.js @@ -6,7 +6,7 @@ jQuery(function($) { // Make the context correct by replacing new_ with the generated ID // of each of the parent objects - var context = ($(this).closest('.fields').find('input:first').attr('name') || '').replace(new RegExp('\[[a-z]+\]$'), ''); + var context = ($(this).closest('.fields').find('input:first').attr('name') || '').replace(new RegExp('\[[a-z_]+\]$'), ''); // context will be something like this for a brand new form: // project[tasks_attributes][new_1255929127459][assignments_attributes][new_1255929128105]