如何在 Rails 5 应用程序中访问远程 mLab 开发数据库?

How do I access remote mLab development db in Rails 5 app?

我目前正在使用 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 访问远程数据库。我错过了什么?

已解决。不得不将 Rails 安装降级到 4.2.7 和 mongoid 4。工作起来非常棒。

我使用与您配置数据库相同的语法,它仍然对我有用 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)