You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting error NoMethodError: undefined method 'yaml_column_permitted_classes=' for ActiveRecord::Base:Class after migrating to Rails 7 with attr_encrypted 4.0.0
Expected behaviour
Getting this error when I run the migrate command
bundle exec rails db:migrate --trace
Current Behaviour
Application runs into an error (with stacktrace below)
Complete stacktrace
rails aborted!
NoMethodError: undefined method `yaml_column_permitted_classes=' for ActiveRecord::Base:Class
/Users/xxxx/.gem/ruby/2.7.7/gems/activerecord-7.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/Users/xxxx/.gem/ruby/2.7.7/gems/attr_encrypted-4.0.0/lib/attr_encrypted.rb:308:in `method_missing'
/Users/xxxx/.gem/ruby/2.7.7/gems/attr_encrypted-4.0.0/lib/attr_encrypted/adapters/active_record.rb:142:in `method_missing_with_attr_encrypted'
/Users/xxxx/.gem/ruby/2.7.7/gems/activerecord-7.0.0/lib/active_record/railtie.rb:263:in `block (3 levels) in <class:Railtie>'
/Users/xxxx/.gem/ruby/2.7.7/gems/activerecord-7.0.0/lib/active_record/railtie.rb:253:in `each'
/Users/xxxx/.gem/ruby/2.7.7/gems/activerecord-7.0.0/lib/active_record/railtie.rb:253:in `block (2 levels) in <class:Railtie>'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
/Users/xxxx/.gem/ruby/2.7.7/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
/Users/xxxx/.gem/ruby/2.7.7/gems/activerecord-7.0.0/lib/active_record/railtie.rb:236:in `block in <class:Railtie>'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/initializable.rb:32:in `instance_exec'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/initializable.rb:32:in `run'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/initializable.rb:61:in `block in run_initializers'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:347:in `each'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:347:in `call'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
/Users/xxxx/.rubies/ruby-2.7.7/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/initializable.rb:60:in `run_initializers'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/application.rb:369:in `initialize!'
/Users/xxxx/applications/myapp/config/environment.rb:7:in `<top (required)>'
/Users/xxxx/.gem/ruby/2.7.7/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
/Users/xxxx/.gem/ruby/2.7.7/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/application.rb:345:in `require_environment!'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/application.rb:507:in `block in run_tasks_blocks'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:281:in `block in execute'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:281:in `each'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:281:in `execute'
/Users/xxxx/.gem/ruby/2.7.7/gems/sentry-ruby-5.4.2/lib/sentry/rake.rb:24:in `execute'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:241:in `each'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:241:in `each'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/task.rb:188:in `invoke'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:182:in `invoke_task'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:138:in `each'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:138:in `block in top_level'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:147:in `run_with_threads'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:132:in `top_level'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/xxxx/.gem/ruby/2.7.7/gems/rake-13.1.0/lib/rake/rake_module.rb:59:in `with_application'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/command.rb:51:in `invoke'
/Users/xxxx/.gem/ruby/2.7.7/gems/railties-7.0.0/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:5:in `require'
bin/rails:5:in `<main>'
I assume you are setting config.active_record.yaml_column_permitted_classes = [some classes] in your application config? And for a given class in that config, does it have attr_encrypted fields?
Yea, should have mentioned that, sorry. I am setting yaml_column_permitted_classes in the application config. But they are non-activerecord classes (so no classes with attr_encrypted fields)
config.active_record.yaml_column_permitted_classes = [
Symbol,
Time,
ActiveSupport::TimeWithZone
]
Removing this configuration works, but I'm curious as to why the same configuration did not cause an issue with an older setup (Rails 6.1 with attr_encrypted 3.1.0)
Yea, should have mentioned that, sorry. I am setting yaml_column_permitted_classes in the application config. But they are non-activerecord classes (so no classes with attr_encrypted fields)
config.active_record.yaml_column_permitted_classes = [
Symbol,
Time,
ActiveSupport::TimeWithZone
]
Removing this configuration works, but I'm curious as to why the same configuration did not cause an issue with an older setup (Rails 6.1 with attr_encrypted 3.1.0)
In a test app I have Rails/ActiveSupport 7.0.4.3 with attr_encrypted4.0.0 and setting the following does not seem to break migrations. Do you have pending migrations, trying to see how this might be hitting our method_missing hook.
Not really sure if this could be because of pending migrations. I get the same error if I run bundle exec rails db:drop --trace as well. My app is using activesupport version 7.0.0. Let me try updating the gem to latest patch version to see if it resolves the issue.
Getting error
NoMethodError: undefined method 'yaml_column_permitted_classes=' for ActiveRecord::Base:Class
after migrating to Rails 7 with attr_encrypted 4.0.0Expected behaviour
Getting this error when I run the migrate command
Current Behaviour
Application runs into an error (with stacktrace below)
Complete stacktrace
Context
Rails version: 7.0.0
attr-encrypted version: 4.0.0
The text was updated successfully, but these errors were encountered: