views:

30

answers:

0

I'm using MongoId 1.9.1, I defined a class like following:

class P
  include Mongoid::Document
  field :s, :type=>Array
end

We can see, the type of field 's' is String, but:

p = P.new
p.s = {:a=>1, :b=>2}
p.save()

It's saved with no error! And can be queried:

>> P.find(:last)
=> #<P _id: 4c3f0159e138231105000006, x: nil, s: {"b"=>2, "a"=>1}>

I don't understand, why a hash can be saved to a Array field?