Guest User

Untitled

a guest
Jan 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. require 'mongoid'
  2. # MongoDB ENV vars
  3. # export MONGOID_HOST='localhost'
  4. # export MONGOID_PORT='27017'
  5. # export MONGOID_USERNAME='billy'
  6. # export MONGOID_PASSWORD='iambilly'
  7. # export MONGOID_DATABASE='billys_db'
  8.  
  9. File.open(File.join(RAILS_ROOT, 'config/mongodb.yml'), 'r') do |f|
  10. @settings = YAML.load(f)[RAILS_ENV]
  11. end
  12. port = @settings["port"].nil? ? Mongo::Connection::DEFAULT_PORT : @settings["port"]
  13.  
  14. connection = Mongo::Connection.new(@settings["host"], port )
  15. Mongoid.database = connection.db(@settings["database"])
  16. Mongoid.configure do |config|
  17. config.allow_dynamic_fields = true
  18. end
Add Comment
Please, Sign In to add comment