I'm facing an issue when trying to use the find_or_initialize_with_errors method from Devise with the required_attributes parameter as a symbol. When I use the symbol as the value for the required_attributes parameter, the method fails to properly retrieve the keys from the hash and returns an empty hash, resulting in an exception.
This issue occurs when the reset_password_by_token method from Devise's Recoverable module is called in the PasswordController. The reset_password_by_token method calls find_or_initialize_with_errors_by with the required_attributes parameter as a symbol, causing the method to fail.
Upon investigating the issue, I realized that the method tries to transform the attributes parameter into a hash with indifferent keys using the with_indifferent_access method. However, when required_attributes is a symbol, the slice method fails to properly retrieve the keys from the hash, resulting in an empty hash.
To work around the issue, I used the required_attributes parameter as an array of strings. However, I believe the method should work properly with the required_attributes parameter as a symbol.
Thanks.
Environment
Ruby [3.2]
Rails [7.0]
Devise [4.8.1]
Expected behavior
I believe the method should work properly with the required_attributes parameter as a symbol.
Pre-check
I'm facing an issue when trying to use the find_or_initialize_with_errors method from Devise with the required_attributes parameter as a symbol. When I use the symbol as the value for the required_attributes parameter, the method fails to properly retrieve the keys from the hash and returns an empty hash, resulting in an exception.
This issue occurs when the reset_password_by_token method from Devise's Recoverable module is called in the PasswordController. The reset_password_by_token method calls find_or_initialize_with_errors_by with the required_attributes parameter as a symbol, causing the method to fail.
Upon investigating the issue, I realized that the method tries to transform the attributes parameter into a hash with indifferent keys using the with_indifferent_access method. However, when required_attributes is a symbol, the slice method fails to properly retrieve the keys from the hash, resulting in an empty hash.
To work around the issue, I used the required_attributes parameter as an array of strings. However, I believe the method should work properly with the required_attributes parameter as a symbol.
Thanks.
Environment
Expected behavior
I believe the method should work properly with the required_attributes parameter as a symbol.