我新的Rails和mongoid,我有mongoid.yml
文件,它包含的條目如下:mongoid YAML結合環境變量主機
development:
# Configure available database clients. (required)
clients:
# Defines the default client. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: mycollectionname
# Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
這個工作正常發展,然而,在生產中,我想從指定的環境變量主機像ENV['OPENSHIFT_MONGODB_DB_HOST']
+「:」 + ENV['OPENSHIFT_MONGODB_DB_PORT']
我已經試過各種方法,如本
hosts:
- <%= \"#{ENV['OPENSHIFT_MONGODB_HOST']}:#{ENV['OPENSHIFT_MONGODB_PORT']}\" %>
或
hosts:
- #{ENV['OPENSHIFT_MONGODB_HOST']:ENV['OPENSHIFT_MONGODB_PORT']}
等,但沒有工作
您是否也嘗試使用URI,即'uri:<%= ENV ['OPENSHIFT_MONGODB_DB_URL']%>'? –