I have an Array
field in my Mongoid model. I am then pushing a few elements to this array.
Do anyone know why my Array elements gets wrapped in hashes, all with the key "$each"
?
class Website
include Mongoid::Document
include Mongoid::Timestamps
field :visits, type: Array
end
website = Website.create
website.push(visits: Time.zone.now)
website.push(visits: Time.zone.now)
puts website.visits.inspect # => [{"$each"=>[2014-04-01 16:32:43 UTC]}, {"$each"=>[2014-04-01 16:32:43 UTC]}]