Rails Mongoid model

sforce100 · November 29, 2012 · Last by sforce100 replied at November 29, 2012 · 2001 hits

Mongoid model 怎么获得 field 对应的字段类型和名字呢? Model.fields.keys 可以获得名字,对应类型怎么获得呢

MongoDB 没有固定模式,所以要读取一条数据才能确定它有什么字段和类型。

Mongoid 的话用 ModelName.fields 可以获得自己在 Model 里面定义的字段信息。

#1 楼 @Rei 刚刚解决了,谢谢

You need to Sign in before reply, if you don't have an account, please Sign up first.