0

This is odd. I definitely am specifying the adapter and it even prints the hash out with puts in the top line of the rake task. db:migrate works too.

$ rake db:create
{"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false,     "database"=>"craigslist_development", "pool"=>5, "username"=>"root", "password"=>"splitzo",   "host"=>"localhost"}
rake aborted!
database configuration does not specify adapter

any ideas?

Let me know if you need more info.

UPDATE:

I am sure the environment is set correctly as it works when I run rake db:migrate

I notice that it is running the ActiveRecord's establish_connection twice and the second time it is not getting the hash. I added some debugging code

spec = spec.symbolize_keys
puts 'test:' + spec.key?(:adapter).to_s

and I get this:

{"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"appname_development", "pool"=>5, "username"=>"user", "password"=>"password", "host"=>"localhost"} (just prints hash object)

test:true (first time)
test:false (second time)
rake aborted!
database configuration does not specify adapter

It's essentially just this and since it works with other tasks I assume the format is good with no odd whitespace issues etc:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: appname_development
  pool: 5
  username: user
  password: password
  host: localhost

It must be an issue with the logic in my Rakefile?

4

1 に答える 1

1

@Taryn East が言ったように、レーキするには RAILS_ENV を渡す必要があります。

rake db:create RAILS_ENV=developmentトリックを行う必要があります。

于 2014-01-26T23:28:12.143 に答える