ActiveRecord::AdapterNotSpecified database configuration does not specify adapter

后端 未结 7 1764
清歌不尽
清歌不尽 2020-12-06 08:52

When I use heroku open my web app works fine but when I\'m using rails s (localhost) I am running into this error:

ActiveRecord::AdapterNotSpecified database         


        
7条回答
  •  既然无缘
    2020-12-06 09:36

    In my case the reason was in my Rakefile.

    when I run rake db:migrate, I got this:

    rake db:migrate
    rake aborted!
    ActiveRecord::AdapterNotSpecified: The `default_env` database is not configured for the `default_env` environment.
    
    Available databases configurations are:
    
    development
    test
    production
    

    I've found this row in my Rakefile:

    ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])

    and changed with default value: ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'] || 'postgres://localhost/db_name')

    and now it works fine. Details you can find here

提交回复
热议问题