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

时间:2017-01-18 17:34:57

标签: ruby-on-rails mongoid mlab

我目前正在使用mongolab中的现有远程数据库设置新的Rails 5应用程序。我正在使用mongoid。以下是我在development下设置config/mongoid.yml的方式:

database: <insert_database_name>
hosts: 
 - <db_number>.mlab.com

options:
 user: <db_user_username>
 password: <db_user_password>

我甚至尝试用uri内的development字符串替换上面的参数,但没有运气。我希望能够使用rails console访问远程数据库。我错过了什么?

2 个答案:

答案 0 :(得分: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) 

答案 1 :(得分:0)

解决。不得不将Rails安装降级到4.2.7和mongoid 4.工作就像一个魅力。

相关问题