Reputation: 12578
I just installed mongoid. I tried their sample code, it raised a beautiful error with a recommendation "Double check your mongid.yml..." So I went to read their intro at mongoid.org, where they say: "Mongoid configuration can be done through a mongoid.yml
". But I dig it how everyone takes for granted that the noob like me will know where the Heaven that mongoid.yml is. Sure, I could just find -name mongoid.yml
, but isn't this weird? Is this a kind of harrowing that every new Mongoid user have to go through?
Edit: OK., this is exactly what I've sporked from Mongoid website.
require 'mongoid'
class Human
include Mongoid::Document
field :name, type: String
embeds_many :interests
end
class Interest
include Mongoid::Document
field :content, type: String
embedded_in :human
end
ccfu = Human.where( name: "John Doe" )
ccfu.interests.create( content: "criminal activity" )
Upvotes: 2
Views: 1310
Reputation: 19238
If you are not using Ruby on Rails you can put mongoid.yml
wherever you like and then in your code you can load it using the load!
method:
Mongoid.load!('path/to/mongoid.yml', :development)
Or:
ENV['MONGOID_ENV'] = 'development'
Mongoid.load!('path/to/mongoid.yml')
On Ruby on Rails it is inside the config
directory.
Upvotes: 4