gpt4 book ai didi

ruby-on-rails - rake 测试准备 : NoMethodError: undefined method `[]' for nil:NilClass

转载 作者:数据小太阳 更新时间:2023-10-29 08:26:37 24 4
gpt4 key购买 nike

当我运行 rake db:test:prepare 时,我总是得到以下错误。什么会导致这个? rake db:create 工作正常。

 Adam-MacBook-Pro:katy adam$ bundle exec rake db:test:prepare
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/adam/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:163:in `purge'
/Users/adam/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:356:in `block (3 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:362:in `block (3 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
/Users/adam/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

数据库.yml

<%= Rails.env %>:
adapter: mysql2
encoding: utf8
pool: <%= ENV['DB_POOL'] || 5 %>
username: <%= ENV['DB_USER'] || 'root' %>
password: <%= ENV['DB_PASSWORD'] || nil %>
timeout: <%= ENV['DB_TIMEOUT'] || 5000 %>
host: <%= ENV['DB_HOST'] || 'localhost' %>
port: <%= ENV['DB_PORT'] || 3306 %>
database: <%= ENV['DB_NAME'] || "website#{Rails.env}" %>

最佳答案

尝试在运行 rake 命令时指定 RAILS_ENV:

RAILS_ENV=test bundle exec rake db:test:prepare

关于ruby-on-rails - rake 测试准备 : NoMethodError: undefined method `[]' for nil:NilClass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32949591/

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