5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rails generate が全然動かない!時に試すこと

Last updated at Posted at 2020-06-05

railsでコントローラーを作ろうと思ったら...

Rails 6.0.3.1 にて
いいね機能を実装すべく、likes_controller.rbを作りたくて以下のコマンドを実行しました。

$ rails g controller likes

...うんともすんとも言わない:cry:

止めよう(^Cぽち)

^CTraceback (most recent call last):
	16: from bin/rails:3:in `<main>'
	15: from bin/rails:3:in `load'
	14: from /リポジトリ名/bin/spring:15:in `<top (required)>'
	13: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	12: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	11: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
	10: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
	 9: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
	 8: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
	 7: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
	 6: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/rails.rb:24:in `call'
	 5: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
	 4: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/run.rb:35:in `call'
	 3: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/run.rb:42:in `warm_run'
	 2: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/run.rb:62:in `run'
	 1: from /Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/run.rb:117:in `verify_server_version'
/Users/ユーザー名/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/client/run.rb:117:in `gets': Interrupt

うわ
どうやらspringというのが怪しい:thinking:

解決方法

springを止めちゃいます。:upside_down:

$ spring stop
Spring stopped.

止まります。
rails g を再度実行!

$ rails g controller likes
Running via Spring preloader in process 23035
      create  app/controllers/likes_controller.rb
      invoke  erb
      create    app/views/likes
      invoke  test_unit
      create    test/controllers/likes_controller_test.rb
      invoke  helper
      create    app/helpers/likes_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    scss
      create      app/assets/stylesheets/likes.scss

できた:raised_hands:

ちなみに

さっき止めたspringですが、ステータスを確認するとしっかり動いていると思います。:runner_tone2:

$ spring status
Spring is running:

参考

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?