factory_bot_rails: undefined method `config' for nil:NilClass after upgrading to 6.4.0

Description

After the update to 6.4, when starting my rails app I get: /home/maraud/.rvm/gems/ruby-3.0.4/gems/railties-7.0.4/lib/rails.rb:47:in configuration’: undefined method config' for nil:NilClass (NoMethodError)

Downgrade to 6.2.X solve the issue

Reproduction Steps

Upgrade factory bot rails to 6.4.0 Try to launch puma

Expected behavior

The rails app should be able to initailize or steps on how to make it work with 6.4 should be provided

Actual behavior

/home/maraud/.rvm/gems/ruby-3.0.4/gems/railties-7.0.4/lib/rails.rb:47:in configuration’: undefined method config' for nil:NilClass (NoMethodError)

System configuration

factory_bot_rails version: 6.4.0 factory_bot version: 6.4.0 rails version: 7.0.4 ruby version: 3.0.4

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 89
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Also experiencing this on 6.4.0 with Rails 7.1.2 and Ruby 3.1.4

I’m still getting the undefined method 'config' for nil:NilClass with factory_bot 6.4.2 and factory_bot_rails 6.4.0. The error is within the factory_bot_rails gem, so I don’t expect updates to factory_bot to resolve this issue.

Also experiencing this on 6.4.0 with Rails 7.0.8 and Ruby 3.2.2.

Workaround is to specify it with gem 'factory_bot_rails', require: false in the Gemfile and do a require 'factory_bot_rails' in spec/rails_helper.rb

Closing this, as factory_bot_rails 6.4.2 fixed the issue. Please note factory_bot 6.4.2 was released before and has nothing to do with this issue.

I can confirm that 6.4.2 has fixed the issue for me that I was seeing in 6.4.0.

I assume this can be closed since https://github.com/thoughtbot/factory_bot_rails/pull/440 got merged and factory_bot_rails 6.4.2 got released?

I’m still getting the undefined method 'config' for nil:NilClass with factory_bot 6.4.2 and factory_bot_rails 6.4.0. The error is within the factory_bot_rails gem, so I don’t expect updates to factory_bot to resolve this issue.

I’m also still having the issue. 6.4.2 did not fix it for me. The highest working version for me is: factory_bot 6.2.1 factory_bot_rails 6.2.0

@jarl-dk You have to revert to 6.2.0 for things to work again.

The work around just make it fail later on the factory internals 🤔

here to be precise https://github.com/thoughtbot/factory_bot_rails/blob/3346305320df35eadae4ac942e44fa7adbbfa574/lib/factory_bot_rails/factory_validator/active_record_validator.rb#L7

     NoMethodError:
       undefined method `<' for nil:NilClass