前提・実現したいこと
railsでコントローラーを作成しようとしたら、以下のようなエラーメッセージが出てきました。
解決法を教えて下さい。
よろしくお願いいたします。
発生している問題・エラーメッセージ
[vagrant@localhost flowershare]$ rails g controller Users /home/vagrant/engineers/flowershare/config/routes.rb:2:in `block in <main>': undefined method `devise_for' for #<ActionDispatch::Routing::Mapper:0x00000000022170d0> (NoMethodError) from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionpack-6.1.3/lib/action_dispatch/routing/route_set.rb:427:in `instance_exec' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionpack-6.1.3/lib/action_dispatch/routing/route_set.rb:427:in `eval_block' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionpack-6.1.3/lib/action_dispatch/routing/route_set.rb:409:in `draw' from /home/vagrant/engineers/flowershare/config/routes.rb:1:in `<main>' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:47:in `block in load_paths' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:47:in `each' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:47:in `load_paths' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:21:in `reload!' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:35:in `block in updater' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/file_update_checker.rb:83:in `execute' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:10:in `execute' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/finisher.rb:195:in `block in <module:Finisher>' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:32:in `instance_exec' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:32:in `run' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:61:in `block in run_initializers' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:347:in `each' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:347:in `call' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:60:in `run_initializers' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:384:in `initialize!' from /home/vagrant/engineers/flowershare/config/environment.rb:5:in `<main>' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require' from /home/vagrant/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require' from -e:1:in `<main>'
###問題が発生するまでの流れ・手順
- アプリを作るディレクトリを作成
- rails new で新規作成
- 必要なGemをGemfileに追記
- Gemを追記したらbundle install
- データベース作成
- モデルを作成
- migrationファイルにテーブル設定を書く
- modelにアソシエーションを書く
- ルーティングを設定
補足情報(FW/ツールのバージョンなど)
Rails 6.1.3
ruby 2.7.1
Vagrant 2.2.14
centos7
回答1件
あなたの回答
tips
プレビュー