We've moved discussions to Discord

NoMethodError related to attr_encrypted after upgrading to Rails 7

Stephen Huey
I'm trying to help someone upgrade a late 2021 Rails 6.1 Jumpstart app to Rails 7 and have run into a vague error message.  Not sure if attr_encrypted being used by User::ConnectedAccount has anything to do with it or if we're supposed to remove that code now or what.  I've searched the discussions here but the closest clues I found didn't really help me:

https://jumpstartrails.com/discussions/rails-7

https://jumpstartrails.com/discussions/nomethoderror-for-class-connectedaccount-solved

In case it matters, I was specifically upgrading from Rails 6.1.4 to 7.0.2.3 and I followed the easy RailsGuides steps.  After running

rails app:update

I added back some Jumpstart-related stuff to application.rb and environment.rb and others but I also noticed this mystery migration had appeared:  
# This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
  def change
    change_column_null(:active_storage_blobs, :checksum, true)
  end
end

I'm unable to successfully migrate due to this vague error:

rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
== 20220402214003 RemoveNotNullOnActiveStorageBlobsChecksum: migrating ========
-- change_column_null(:active_storage_blobs, :checksum, true)
   -> 0.0067s
== 20220402214003 RemoveNotNullOnActiveStorageBlobsChecksum: migrated (0.0073s)

rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `key?' for nil:NilClass
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `block in perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `reject'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:36:in `assign_attributes'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/core.rb:468:in `initialize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/persistence.rb:54:in `create!'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1395:in `record_version_state_after_migrating'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/transactions.rb:209:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1410:in `ddl_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1358:in `execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `migrate_without_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `block in migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1431:in `block in with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1446:in `with_advisory_lock_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1427:in `with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1116:in `up'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1091:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/tasks/database_tasks.rb:260:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/strong_migrations-0.7.9/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rake.rb:20:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/command.rb:51:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `<main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:4:in `<main>'

Caused by:
NoMethodError: undefined method `key?' for nil:NilClass
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `block in perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `reject'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:36:in `assign_attributes'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/core.rb:468:in `initialize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/persistence.rb:54:in `create!'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1395:in `record_version_state_after_migrating'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/transactions.rb:209:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1410:in `ddl_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1358:in `execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `migrate_without_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `block in migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1431:in `block in with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1446:in `with_advisory_lock_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1427:in `with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1116:in `up'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1091:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/tasks/database_tasks.rb:260:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/strong_migrations-0.7.9/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rake.rb:20:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/command.rb:51:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `<main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
➜

I'm still seeing the error about the key even if I remove the migration.   I'm wondering how relevant this is, and I did try copying the generated YAML credentials into the files for the different environments, but I'm not exactly sure if this matters for our project:

https://pagertree.com/2021/04/13/rails-7-attr-encrypted-migration/

Any help getting past this would be greatly appreciated!  
Stephen Huey
Ah, I removed attr_encrypted from the Gemfile and was able to run that migration and run the app, but when trying to browse to the admin area I ran into an error so I commented out these related lines in User::ConnectedAccount:
#attr_encrypted :access_token, key: Base64.decode64(Rails.application.credentials.access_token_encryption_key)
#attr_encrypted :access_token_secret, key: Base64.decode64(Rails.application.credentials.access_token_encryption_key), allow_empty_value: true
and
# Safely handles empty strings before attempting encryption
#def safe_access_token_secret=(value)
#  return if value.blank?
#  __send__("attr_encrypted_access_token_secret=", value)
#end

# Replace the dynamically defined attr_encrypted method with our own
#alias_method :attr_encrypted_access_token_secret=, :access_token_secret=
#alias_method :access_token_secret=, :safe_access_token_secret=

If I have zero User::ConnectedAccount records in the database and am not using it and have no plans to support Omniauth providers, is that enough?  I also found https://gorails.com/episodes/migrate-attr_encrypted-to-rails-7-encryption so I'm wondering if we need to do any of that or if we can skip it.  

In other words, what's the recommended path for upgrading the Rails version for a stock Jumpstart app?  
Stephen Huey
I'm trying to help someone upgrade a late 2021 Rails 6.1 Jumpstart app to Rails 7 and have run into a vague error message.  Not sure if attr_encrypted being used by User::ConnectedAccount has anything to do with it or if we're supposed to remove that code now or what.  I've searched the discussions here but the closest clues I found didn't really help me:

https://jumpstartrails.com/discussions/rails-7

https://jumpstartrails.com/discussions/nomethoderror-for-class-connectedaccount-solved

In case it matters, I was specifically upgrading from Rails 6.1.4 to 7.0.2.3 and I followed the easy RailsGuides steps.  After running

rails app:update

I added back some Jumpstart-related stuff to application.rb and environment.rb and others but I also noticed this mystery migration had appeared:  
# This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
  def change
    change_column_null(:active_storage_blobs, :checksum, true)
  end
end

I'm unable to successfully migrate due to this vague error:

rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
== 20220402214003 RemoveNotNullOnActiveStorageBlobsChecksum: migrating ========
-- change_column_null(:active_storage_blobs, :checksum, true)
   -> 0.0067s
== 20220402214003 RemoveNotNullOnActiveStorageBlobsChecksum: migrated (0.0073s)

rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `key?' for nil:NilClass
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `block in perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `reject'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:36:in `assign_attributes'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/core.rb:468:in `initialize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/persistence.rb:54:in `create!'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1395:in `record_version_state_after_migrating'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/transactions.rb:209:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1410:in `ddl_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1358:in `execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `migrate_without_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `block in migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1431:in `block in with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1446:in `with_advisory_lock_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1427:in `with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1116:in `up'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1091:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/tasks/database_tasks.rb:260:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/strong_migrations-0.7.9/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rake.rb:20:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/command.rb:51:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `<main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:4:in `<main>'

Caused by:
NoMethodError: undefined method `key?' for nil:NilClass
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `block in perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `reject'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in `perform_attribute_assignment'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:36:in `assign_attributes'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/core.rb:468:in `initialize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/inheritance.rb:75:in `new'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/persistence.rb:54:in `create!'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1395:in `record_version_state_after_migrating'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/transactions.rb:209:in `transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1410:in `ddl_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1358:in `execute_migration_in_transaction'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1332:in `migrate_without_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `block in migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1431:in `block in with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1446:in `with_advisory_lock_connection'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1427:in `with_advisory_lock'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1281:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1116:in `up'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/migration.rb:1091:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/tasks/database_tasks.rb:260:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/strong_migrations-0.7.9/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.2.3/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rake.rb:20:in `execute'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/command.rb:51:in `invoke'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `<main>'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/stephen/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
➜

I'm still seeing the error about the key even if I remove the migration.   I'm wondering how relevant this is, and I did try copying the generated YAML credentials into the files for the different environments, but I'm not exactly sure if this matters for our project:

https://pagertree.com/2021/04/13/rails-7-attr-encrypted-migration/

Any help getting past this would be greatly appreciated!  
Stephen Huey
Ah, I removed attr_encrypted from the Gemfile and was able to run that migration and run the app, but when trying to browse to the admin area I ran into an error so I commented out these related lines in User::ConnectedAccount:
#attr_encrypted :access_token, key: Base64.decode64(Rails.application.credentials.access_token_encryption_key)
#attr_encrypted :access_token_secret, key: Base64.decode64(Rails.application.credentials.access_token_encryption_key), allow_empty_value: true
and
# Safely handles empty strings before attempting encryption
#def safe_access_token_secret=(value)
#  return if value.blank?
#  __send__("attr_encrypted_access_token_secret=", value)
#end

# Replace the dynamically defined attr_encrypted method with our own
#alias_method :attr_encrypted_access_token_secret=, :access_token_secret=
#alias_method :access_token_secret=, :safe_access_token_secret=

If I have zero User::ConnectedAccount records in the database and am not using it and have no plans to support Omniauth providers, is that enough?  I also found https://gorails.com/episodes/migrate-attr_encrypted-to-rails-7-encryption so I'm wondering if we need to do any of that or if we can skip it.  

In other words, what's the recommended path for upgrading the Rails version for a stock Jumpstart app?  
Notifications
You’re not receiving notifications from this thread.
© 2022 Jumpstart Pro by GoRails, LLC