railsで「sqllite」から「mysql」に変更してから「rails g model テーブル名 カラム」 のコマンドが実行できません。
エラーコードは以下の通り
matsurawataru@matsuurawatarunoMacBook-Pro pokeGO % rails g model Pokemon /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/application/configuration.rb:231:in `database_configuration': Cannot load database configuration: undefined method `each' for "use# SQLite. Versions 3.8.0 and up are supported.":String (NoMethodError) from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/railtie.rb:200:in `block (2 levels) in <class:Railtie>' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:71:in `class_eval' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:51:in `each' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/base.rb:327:in `<module:ActiveRecord>' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/base.rb:27:in `<main>' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.9/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.9/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.9/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.9/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.9/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:376:in `active_record_configured?' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:293:in `disconnect_database' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:111:in `preload' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/matsurawataru/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from -e:1:in `<main>'
database.ymlのコードは以下の通り
use# SQLite. Versions 3.8.0 and up are supported. # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' # default: &default adapter: mysql2 encoding: utf8 pool: 5 username: root password: root host: localhost development: <<: *default database: pokeGO_development # DBの名前。「sample」の部分をアプリの名前に変更すると分かりやい username: pokemonGO password: pokepoke test: <<: *default database: pokeGO_test # DBの名前。「sample」の部分をアプリの名前に変更すると分かりやい production: <<: *default database: pokeGO_production username: pokeGO_app password: <%= ENV['SAMPLE_DATABASE_PASSWORD'] %>
他にどのファイルのコードを貼っていいかわからないので、必要な場合は追記します。
分かる方いらっしゃいましたらご教授よろしくお願い致します。
回答2件
あなたの回答
tips
プレビュー