-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rails 6 active model error deprecations #22
Fix rails 6 active model error deprecations #22
Conversation
This fix resolves the following warning : " DEPRECATION WARNING: Enumerating ActiveModel::Errors as a hash has been deprecated. In Rails 6.1, `errors` is an array of Error objects, therefore it should be accessed by a block with a single block parameter like this: person.errors.each do |error| attribute = error.attribute message = error.message end You are passing a block expecting two parameters, so the old hash behavior is simulated. As this is deprecated, **this will result in an ArgumentError in Rails 6.2**. " see also https://api.rubyonrails.org/v6.1.3.2/classes/ActiveModel/Errors.html#method-i-each
This fix resolves the following error: " FrozenError: can't modify frozen Array: ["is invalid"] " The ActiveModel::Error is not a simple Hash anymore: now is a first citizen Object. See also: * https://api.rubyonrails.org/v6.1.3.2/classes/ActiveModel/Error.html * https://blog.saeloun.com/2020/06/17/rails-active-model-errors.html#after
This fix resolves the following error during the tests execution: " Failure/Error: DatabaseCleaner.cleaning { example.run } ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found. " Change the original gem to a more specific one: database_cleaner-mongoid DBCleaner configuration moved to a distinct file see https://github.com/DatabaseCleaner/database_cleaner-mongoid
Hey there @knovoselic - assuming you're still a maintainer for this repo, would it be possible to get this merged and released? Given Rails 7 is out, my assumption is that those deprecation warnings will now turn into errors. It'd be great to be able to keep using this helpful gem! Thanks! |
Glad to see some other user of this gem! 😄 |
@AlessSala sorry it took so long for us to look at this we haven't touched this gem in ages. @knovoselic this looks good to me. Only thing we might want to consider is adding a rails version requirement in mongoid-embedded-errors.gemspec? |
Playing around with different versions we need to add a dependency of activemodel >= 6.1 |
@AlessSala thanks for the PR and so sorry for the long wait. We'll try to do better from now! |
This pull request aims to fix the following issues raised using Rails 6.1.x:
Please check the commit messages for an in-depth explanation: sources and links are also there.
Rspec test run smoothly.
Thank you for your useful gem - feel free to scold me if anything sounds wrong to you.
Greetings, Alessandro.