【问题标题】:How do I access remote mLab development db in Rails 5 app?如何在 Rails 5 应用程序中访问远程 mLab 开发数据库?
【发布时间】:2017-06-03 05:08:48
【问题描述】:
我目前正在 mongolab 中使用现有的远程数据库设置一个新的 Rails 5 应用程序。我正在使用mongoid。以下是我在config/mongoid.yml 下设置development 的方法:
database: <insert_database_name>
hosts:
- <db_number>.mlab.com
options:
user: <db_user_username>
password: <db_user_password>
我什至尝试用development 中的uri 字符串替换上述参数,但没有运气。我希望能够使用rails console 访问远程数据库。我错过了什么?
【问题讨论】:
标签:
ruby-on-rails
mongoid
mlab
【解决方案1】:
我使用与配置数据库相同的语法,它仍然适用于我的 rails 5 和 mongoid 5。这是我设置的。希望有帮助!!
database: manga_app
hosts:
- ds151108.mlab.com:51108
options:
# The name of the user for authentication.
user: 'xxx' (xxx is the username you set for database not the name you use to sign in)
# The password of the user for authentication.
password: 'yyy' (yyy is the password you set for the database not the password you use to sign in)
【解决方案2】:
已解决。不得不将 Rails 安装降级到 4.2.7 和 mongoid 4。就像一个魅力。