Skip to content

Commit

Permalink
Fix error component without object on Rails main to display properly
Browse files Browse the repository at this point in the history
Rails main changed `object` to be `false` instead of `nil`, causing the
specific check we were doing for `object.nil?` to fail, and the custom
errors were not displaying for forms without an object. Our test suite
caught that, and the fix is to simply not check specifically for `nil?`,
but just whether we have an object or not, which should account for both
`nil`/`false` versions.

It's a small backwards incompatibility, probably not something worth
changing the framework for, but one worth mentioning.

Source is likely to be:
- rails/rails#49943
- rails/rails#50931
  • Loading branch information
carlosantoniodasilva committed Apr 9, 2024
1 parent 416894a commit 5103d7d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/simple_form/components/errors.rb
Expand Up @@ -11,7 +11,7 @@ def full_error(wrapper_options = nil)
end

def has_errors?
object_with_errors? || object.nil? && has_custom_error?
object_with_errors? || !object && has_custom_error?
end

def has_value?
Expand Down

0 comments on commit 5103d7d

Please sign in to comment.