Ruby-on-rails – How to use FactoryBot in db/seeds

factory-botruby-on-railsseed

Is it possible to do this?

If so, how can you do it?

Note: FactoryBot was previously named FactoryGirl

Best Answer

All you need to do is add require 'factory_bot_rails' to the db/seeds.rb file. This will give you access to your factories.

Note: Gem was previously called FactoryGirlRails