gpt4 book ai didi

ruby-on-rails - 未定义的方法获取错误 :FalseClass

转载 作者:行者123 更新时间:2023-12-04 03:30:33 25 4
gpt4 key购买 nike

我创建了一个简单的 rails 应用程序,当我运行 rails 时。它发出这堆错误:-s 我试图重新安装 activerecord 但它无法解决问题。此外,我尝试使用 rvm 删除所有 gemset 并重新安装,但它仍然相同。

/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:33:in `resolve_string_connection': undefined method `fetch' for false:FalseClass (NoMethodError)
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:23:in `spec'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:127:in `establish_connection'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/railtie.rb:76:in `block (2 levels) in <class:Railtie>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:25:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/vic4ever/crowdvn/crowd.vn/config/environment.rb:5:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /home/vic4ever/crowdvn/crowd.vn/config.ru:4:in `block in <main>'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/vic4ever/crowdvn/crowd.vn/config.ru:1:in `new'
from /home/vic4ever/crowdvn/crowd.vn/config.ru:1:in `<main>'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

最佳答案

您需要一个数据库适配器(即 config/database.yml )。

我将假设您使用 Git 进行源代码控制以确保您的安全。当您按照以下说明进行操作时,它还可以帮助您查看所做的更改。

生成新 database.yml :

$ cd ~/path/to/my-existing-rails-app
$ rails new my-existing-rails-app --database=sqlite

一系列提示将询问您是否要创建/覆盖现有文件。继续对提示回答“否”,直到您看到一个要求创建 config/database.yml 的提示。 .如果您看到提示,请回答"is",然后继续对其他人回答“否”。

而不是 --database=sqlite ,您也可以使用 --database=postgresql--database=mysql如果您在本地/开发环境中安装了它们。

更进一步, --database=DATABASE 还有更多选择。
mysql
oracle
postgresql
sqlite3
frontbase
ibm_db
sqlserver
jdbcmysql
jdbcsqlite3
jdbcpostgresql
jdbc

关于ruby-on-rails - 未定义的方法获取错误 :FalseClass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10331569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com