How can I get all field names of the Mongoid Document?

前端 未结 4 688
孤街浪徒
孤街浪徒 2021-02-02 13:36

I\'m building backend system, as written in Iain Hecker\'s tutorial: http://iain.nl/backends-in-rails-3-1 and I try to adapt it to MongoDB with Mongoid.

So when I need t

4条回答
  •  感动是毒
    2021-02-02 14:08

    One thing to take note of is that Model.fields.keys will only list the field keys that are defined in the Model class. If you use dynamic fields they will not be shown. Model.attributes.keys will also include the attribute keys for any dynamic fields you have used.

提交回复
热议问题