1
0

More than 3 years have passed since last update.

Could not find generator 'factory_bot:model'. でファクトリが作成できないとき

Last updated at Posted at 2019-12-16

ファクトリが作成できない

コマンドが見つからないようで、実行できない。。

$ rails g factory_bot:model user
Running via Spring preloader in process 81847
Could not find generator 'factory_bot:model'. 
Run `rails generate --help` for more options.

解決策

古いプロセスに接続していることが原因でした。
下記で停止して、

$ spring stop

もう一回ファクトリを作成すると、

$ rails g factory_bot:model user
Running via Spring preloader in process 89115
      create  spec/factories/users.rb

成功しました!

おまけ:springはアプリケーションプリローダー

Springとは、Rails4.1から標準で付属するようになったアプリケーションプリローダーです。
Rails内では様々なライブラリのロードなどの前処理が行われるので、コマンドを実行するための待ち時間がかかってしまいます。
事前にバックグラウンドでライブラリをロードしておくことで、その待ち時間を短くするものがアプリケーションプリローダーです。

railsコマンドを素早く実行するためのライブラリだったんですね。

参考

Rails 4 + react-rails gem: Could not find generator 'react:install'

Railsの開発効率をあげる - Springを使ってRailsのコンソールコマンドの実行を早くする

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0