标签: ruby mongomapper
我有以下课程:
class Stock include MongoMapper::Document key :name, String key :isin, String end
如何在运行时确定Stock类的键名?
Stock
答案 0 :(得分:2)
使用keys方法:
keys
Stock.keys #=> ["name", "isin"]