2
我在mongoid中有一个验证,如果它在保存错误信息时失败了,我想恢复它。Mongoid恢复失败
例
if @thing.update_attributes(params[:thing])
format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }
format.json { head :no_content }
else
#revert the fields that have changed and keep @thing.errors
format.html { render action: "edit" }
format.json { render json: @thing.errors, status: :unprocessable_entity }
end
当我保存关闭文档,然后重新插入,它似乎不想分配@thing.errors = errors
感谢