ActiveRecord::AdapterNotSpecified database configuration does not specify adapter

后端 未结 7 1761
清歌不尽
清歌不尽 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:52

    You didn't show the command causing this query, but this could happen if you pass a string and not a symbol.

    For example:

    irb(main):001:0> ActiveRecord::Base.establish_connection("#{Rails.env}")
    ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
    

    But then if you use a symbol, it will work.

    irb(main):001:0> ActiveRecord::Base.establish_connection("#{Rails.env}".to_sym)
    => #

提交回复
热议问题