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

前端 未结 4 606
孤街浪徒
孤街浪徒 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:06

    Use the built-in method:

    Model.attribute_names
    # => ["_id", "created_at", "updated_at", "name", "address"]
    

提交回复
热议问题