-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 4.0.0 final
-
Component/s: None
-
None
-
Environment:Ubuntu 14.04
Mongoid works fine on development in a Rails 4 app. However, when I seed my staging environment, the seed does not fail (so I assume Mongoid creates the objects) but when I look at the mongo database on staging no objects are created.
I run the following to seed:
RAILS_ENV=staging bundle exec rake db:seed
In seeds.rb, I have this:
[Role, User, FieldType].each do |model|
puts "seeding #
"
model.seed
end
The ActiveRecord objects are seeded (Role and User) but not the Mongoid object (FieldType). FieldType looks like this:
class FieldType
include Mongoid::Document
field :name
def self.seed
find_or_create_by(name: 'Text')
find_or_create_by(name: 'Number')
end
end
The seed never fails and it seems that it creates the FieldType objects. In my mongoid.yml I have the following:
staging:
sessions:
default:
database: core_staging
hosts:
- localhost:27017
options:
But when I log into my staging server, no core_staging was ever created with the objects.
Why is this happening? Is this a bug or am I missing something from the mongoid.yml? If I am missing something from mongoid.yml that I am not aware of, then I will close this issue.