ruby 无法加载数据库配置:是一个目录

5gfr0r5j  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(88)

我在udemy上买了一个课程,课程中的第一件事是用命令rails server打开服务器,服务器成功启动:

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上”,我的有一堆错误,有人能帮助我吗?

  • 操作系统是Windows。
  • Ruby版本:3.1.4
  • Rails版本:7.0.8

我希望能够访问服务器成功屏幕继续类和测试我的项目设置

mbskvtky

mbskvtky1#

从rails guides:
几乎每个Rails应用程序都会与数据库交互。您可以通过设置环境变量ENV['DATABASE_URL']或使用名为config/database.yml的配置文件连接到数据库。
使用config/database.yml文件,您可以指定访问数据库所需的所有信息
所以config/database.yml必须是文件不是文件夹,就像你的例子一样
您需要删除此文件夹第一,创建(如果不存在)此文件,并填写它一样,在上面的链接
如果它是全新的应用程序和文件是缺席,这将是更快地创建新的应用程序再次
您可以在rails repository中找到基本模板,根据您的RDBMS选择所需的模板

相关问题