Skip to content

Commit e1a1519

Browse files
committed
Handle human names with spaces for JS replacement
When generating the html that form builder's #has_many replaces via JS, the placeholder that it looks for cannot contain spaces, otherwise, JS's replace method won't replace all that it was supposed to. This was originally implemented by @danielwestendorf in PR activeadmin#1789
1 parent ca074de commit e1a1519

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/active_admin/form_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def with_new_form_buffer
173173
def js_for_has_many(association, form_block, template)
174174
association_reflection = object.class.reflect_on_association(association)
175175
association_human_name = association_reflection.klass.model_name.human
176-
placeholder = "NEW_#{association_human_name.upcase}_RECORD"
176+
placeholder = "NEW_#{association_human_name.upcase.split(' ').join('_')}_RECORD"
177177

178178
js = with_new_form_buffer do
179179
inputs_for_nested_attributes :for => [association, association_reflection.klass.new],

0 commit comments

Comments
 (0)