How do I use factories from FactoryGirl in rails console

后端 未结 3 469
无人及你
无人及你 2020-12-22 20:39

I am using rails console in the development environment and I want to use factories. How can I get access to them?

I have tried require \"FactoryGirl\"

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 21:40

    To solve this problem ensure that the factory bot gem is specifed in your Gemfile similar to this

    group :development, :test do
      gem 'factory_bot_rails'
    end
    

    Then bundle install.

    This should make FactoryBot class available in the development console.

    Hope this helps.

提交回复
热议问题