List dynamic attributes in a Mongoid Model

后端 未结 6 1449
醉酒成梦
醉酒成梦 2021-02-06 15:49

I have gone over the documentation, and I can\'t find a specific way to go about this. I have already added some dynamic attributes to a model, and I would like to be able to it

6条回答
  •  没有蜡笔的小新
    2021-02-06 16:38

    Not sure if I liked the clone approach, so I wrote one too. From this you could easily build a hash of the content too. This merely outputs it all the dynamic fields (flat structure)

     (d.attributes.keys - d.fields.keys).each {|a| puts "#{a} = #{d[a]}"};
    

提交回复
热议问题