Skip to content

Commit

Permalink
Revert "Merge pull request #1810 from meanphil/mappings-slow-exception"
Browse files Browse the repository at this point in the history
This reverts commit b6ae67d, reversing
changes made to 0ef4a58.

This caused custom inputs to not load properly on non-eager load
environments like dev/test, because those constants may not have been
defined yet.

The previous code would try to constantize them and force-load the
lazily-loaded files/constants, the new code breaks that behavior, so
we're reverting.

Closes #1824, see for more info.
  • Loading branch information
carlosantoniodasilva committed May 14, 2024
1 parent bad4ce0 commit dc7c9f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased

* Revert "Speed up input mapping lookup by avoiding rescuing exceptions" from v5.3.0, it caused a regression on dev/test environments with custom inputs.
* Add support to Ruby 3.3. (no changes required.)

## 5.3.0
Expand Down
6 changes: 5 additions & 1 deletion lib/simple_form/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,11 @@ def mapping_override(klass)
def attempt_mapping(mapping, at)
return if SimpleForm.inputs_discovery == false && at == Object

at.const_get(mapping) if at.const_defined?(mapping)
begin
at.const_get(mapping)
rescue NameError => e
raise if e.message !~ /#{mapping}$/
end
end

def attempt_mapping_with_custom_namespace(input_name)
Expand Down

0 comments on commit dc7c9f2

Please sign in to comment.