Techioz Blog

データベース構成をロードできません: ディレクトリです

概要

udemy でコースを購入しました。コースで最初に行うことは、コマンド Rails サーバーでサーバーを開くことです。サーバーは正常に起動します。

PS C:\curso ruby\ruby curso udemy\projeto_udemybasico> rails s
=> Booting Puma
=> Rails 7.0.8 application starting in development       
=> Run `bin/rails server --help` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!      
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.12.6 (ruby 3.1.4-p223), codename: Llamas in Pajamas     
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000

ただし、ブラウザでこの localhost:3000 にアクセスすると、多くのエラー行が表示され、VS Code ターミナルにも次の同じエラーが表示されます。

Puma caught this error: Cannot load database configuration:
Is a directory @ rb_sysopen - C:/curso ruby/ruby curso udemy/projeto_udemybasico/config/database.yml (Errno::EISDIR)
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/configuration_file.rb:39:in `read'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/configuration_file.rb:39:in `read'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/configuration_file.rb:14:in `initialize'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/configuration_file.rb:18:in `new'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/configuration_file.rb:18:in `parse'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.8/lib/rails/application/configuration.rb:334:in `database_configuration'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8/lib/active_record/railtie.rb:266:in `block (2 levels) in <class:Railtie>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:95:in `class_eval'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:95:in `block in execute_hook'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:85:in `with_execution_control'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:90:in `execute_hook'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:76:in `block in run_load_hooks'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:75:in `each'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/lazy_load_hooks.rb:75:in `run_load_hooks'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8/lib/active_record/base.rb:333:in `<module:ActiveRecord>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8/lib/active_record/base.rb:15:in `<top (required)>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8/lib/active_record/query_cache.rb:36:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/execution_wrapper.rb:29:in `before'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:423:in `block in make_lambda'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:199:in `block (2 levels) in halting'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:687:in `block (2 levels) in default_terminator'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:686:in `catch'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:686:in `block in default_terminator'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:200:in `block in halting'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:595:in `block in invoke_before'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:595:in `each'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:595:in `invoke_before'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:106:in `run_callbacks'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/execution_wrapper.rb:129:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/execution_wrapper.rb:125:in `run!'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/execution_wrapper.rb:78:in `block in run!'
<internal:kernel>:90:in `tap'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/execution_wrapper.rb:75:in `run!'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-7.0.8/lib/action_dispatch/middleware/executor.rb:12:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-7.0.8/lib/action_dispatch/middleware/static.rb:23:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/sendfile.rb:110:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-7.0.8/lib/action_dispatch/middleware/host_authorization.rb:138:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.8/lib/rails/engine.rb:530:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-3.12.6/lib/puma/configuration.rb:227:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-3.12.6/lib/puma/server.rb:706:in `handle_request'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-3.12.6/lib/puma/server.rb:476:in `process_client'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-3.12.6/lib/puma/server.rb:334:in `block in run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-3.12.6/lib/puma/thread_pool.rb:135:in `block in spawn_thread'

コース中、先生は「こんにちは、Rails を使っています」のような画面を表示しますが、私の場合は大量のエラーが発生しました。誰か助けてくれませんか?

サーバーの成功画面にアクセスして授業を続行し、プロジェクトの設定をテストできるようにしたいです

解決策

レールガイドから:

したがって、config/database.yml は、あなたの場合のようなフォルダーではなく、ファイルである必要があります

まずこのフォルダーを削除し、このファイルを作成し(存在しない場合)、上記のリンクのように入力する必要があります

完全に新しいアプリケーションでファイルが存在しない場合は、再度新しいアプリケーションを作成した方が早いです

Rails リポジトリに基本的なテンプレートがあり、RDBMS に応じて必要なテンプレートを選択できます。