Skip to content

Commit e451998

Browse files
Avoid creating multiple regexp objects
The check is slightly different but should work for our purposes here. Using `end_with?(mapping)` to keep a similar check doesn't work because some Ruby versions include "did you mean", which make the error message look something like this: NameError: uninitialized constant StringInput at.const_get(mapping) ^^^^^^^^^^ Did you mean? StringInputTest The regexp check worked because it was matching the end of the line, not end of string, with `$`, so it'd match the first line of the error message always.
1 parent ae12516 commit e451998

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/simple_form/form_builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def attempt_mapping(mapping, at)
676676
begin
677677
at.const_get(mapping)
678678
rescue NameError => e
679-
raise if e.message !~ /#{mapping}$/
679+
raise unless e.message.include?(mapping)
680680
end
681681
end
682682

0 commit comments

Comments
 (0)