我正在尝试运行命令
rake db:setup RAILS_ENV="production"
但它给出了以下错误:
DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:mysql) instead. (called from call at /home/huzefa/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240)
rake aborted!
ActiveRecord::AdapterNotSpecified: 'mysql' database is not configured. Available: ["default", "development", "test", "production", "adapter", "encoding", "reconnect", "database", "pool", "username", "password", "host"]
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:231:in `resolve_string_connection'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:213:in `resolve_connection'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:151:in `block in resolve_all'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:150:in `each'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:150:in `resolve_all'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:69:in `resolve'
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/core.rb:46:in `configurations='
/home/huzefa/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:5:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create => db:load_config
我的database.yml
文件如下:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
adapter: mysql
encoding: utf8
reconnect: false
database: depot_production
pool: 5
username: huzefa
password: huzefa
host: localhost
这里缺少了什么东西,导致我无法在这里设置生产中的 mysql 数据库?如果有人能帮助我,那就太需要了。谢谢 :)
答案1
database.yml
由于文件中存在缩进错误,因此已解决。