我在开发环境中使用rails控制台,我想使用工厂.我怎样才能接触到他们?
我已经试过require "FactoryGirl"
次了,结果还是回来了
1.9.3p393 :301 > require "FactoryGirl"
LoadError: cannot load such file -- FactoryGirl
我在开发环境中使用rails控制台,我想使用工厂.我怎样才能接触到他们?
我已经试过require "FactoryGirl"
次了,结果还是回来了
1.9.3p393 :301 > require "FactoryGirl"
LoadError: cannot load such file -- FactoryGirl
要解决此问题,请确保在gem文件中指定与此类似的factory bot gem
group :development, :test do
gem 'factory_bot_rails'
end
然后是bundle install
.
这将使FactoryBot类在开发控制台中可用.
希望这有帮助.