我正在使用Mongoid在表上執行批量插入,其中batch是一個哈希數組:批量插入是否可以在Mongodb中進行驗證?
@state = State.new
@state.collection.insert batch
我是否通過這種方式繞過Activerecord?當我嘗試驗證記錄時沒有任何反應。
validates_format_of :population, :with => /\d+/
我也在嘗試執行回調來格式化數據。
before_validation :generate_population
沒有任何反應。
有沒有一種解決方法可以批量插入進行驗證工作? – 2011-03-27 15:50:45
上面添加了註釋 – 2011-03-27 16:09:17