直到最近db:create
工作得很好,但现在它已经失败了我在下面发布的堆栈跟踪。这是String can't be coerced into Fixnum
错误。
这可能是什么原因?
我的密码包含字母和数字,因此this不能成为原因。
跟踪仅指向Rails代码,而不是我自己的代码,这使调试成为一种挑战。
我在模型中注释了使用+
运算符的方法,但这并没有解决任何问题。
我的database.yml
:
development:
adapter: postgresql
database: db/testivate_development
pool: 5
username: steven
password: <redacted>
host: localhost
test: &test
adapter: postgresql
database: db/testivate_test<%= ENV['TEST_ENV_NUMBER'] %>
pool: 5
username: steven
password: <redacted>
host: localhost
production:
adapter: postgresql
database: db/testivate_production
pool: 5
username: steven
password:
cucumber:
<<: *test
追踪:
$ rake db:create
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.9.0
String can't be coerced into Fixnum
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `+'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `block in sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `inject'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:749:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:130:in `rescue in create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:74:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `load'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `<main>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"db/testivate_development", "pool"=>5, "username"=>"steven", "password"=>"<redacted>", "host"=>"localhost"}
String can't be coerced into Fixnum
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `+'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `block in sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `inject'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:749:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:130:in `rescue in create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:74:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `load'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `<main>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"db/testivate_test", "pool"=>5, "username"=>"steven", "password"=>"<redacted>", "host"=>"localhost"}
更新
即使我将所有迁移从/db/migrations/
移到最简单且最明确的database.yml
,我也会收到同样的错误:
development:
adapter: postgresql
database: db/testivate_development
username: "steven"
password: "<redacted>"
host: localhost
test:
adapter: postgresql
database: db/testivate_test
username: "steven"
password: "<redacted>"
host: localhost
答案 0 :(得分:1)
看起来这个bug在enumstats gem中。你把它包含在你的Gemfile中吗?