No database connection in rails console

后端 未结 4 436
春和景丽
春和景丽 2021-02-01 13:37

My rails application works fine when I run rake db:migrate but the problem occurs when I try to start the rails console.

2.0.0p247 :003 > User
 =         


        
4条回答
  •  抹茶落季
    2021-02-01 14:01

    simple solution: The console probably does have a database connection but is reporting that it doesn't.

    To see if that's true, make a query in the console.

    User.count 
    

    That fixed the false positive warning for me and a colleague.

    or

    Use Model.connection to establish a connection.

提交回复
热议问题