简体   繁体   English

ActiveRecord :: ConnectionNotEstablished错误与在轨道上的红宝石

[英]ActiveRecord::ConnectionNotEstablished error with ruby on rails

I was trying to learn ruby on rails, so I installed the gem version 4.0.0, when I start my server, and go to localhost:8000 , it brings me an error page with error message: 我试图学习Rails,所以我安装了gem版本4.0.0,当我启动服务器时,转到localhost:8000 ,它给我一个错误页面,并显示错误消息:

ActiveRecord::ConnectionNotEstablished. ActiveRecord :: ConnectionNotEstablished。

I'm using sqlite3, not MySQL. 我正在使用sqlite3,而不是MySQL。 Any help is appreciated. 任何帮助表示赞赏。

edit: i fixed it, had to do with my database.yml 编辑:我修复它,与我的database.yml有关

Make sure that you have installed sqlite3 gem: gem install sqlite3 or run bundle install if you have the gem listed on your Gemfile (which you should). 确保已安装sqlite3 gem: gem install sqlite3或运行bundle install如果您的Gemfile中列出了gem)(应该这样做)。

After that run the following commands: 之后,运行以下命令:

  • rake db:create # creates the database rake db:create#创建数据库
  • rake db:migrate # creates the tables based on your migration files rake db:migrate#根据您的迁移文件创建表

If the above two works fine, your application should be able to connect to the database. 如果以上两种方法均能正常工作,则您的应用程序应该能够连接到数据库。 If not you probably have a configuration problem on your config/database.yml . 如果不是这样,您可能在config/database.yml上遇到配置问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM