ActiveRecord::AdapterNotSpecified database configuration does not specify adapter

后端 未结 7 1734
清歌不尽
清歌不尽 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)
    => #<ActiveRecord::ConnectionAdapters::ConnectionPool:0x007f2f484a32a0 #....
    
    0 讨论(0)
提交回复
热议问题