From a468b690132224b89bcbdf037e3b4a35a217e566 Mon Sep 17 00:00:00 2001 From: iCross Date: Thu, 6 Jun 2013 23:10:42 +0800 Subject: [PATCH] archive module: fix old data caused error --- app/models/mongoid/sortable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/mongoid/sortable.rb b/app/models/mongoid/sortable.rb index 16a69defb..b22dce08a 100644 --- a/app/models/mongoid/sortable.rb +++ b/app/models/mongoid/sortable.rb @@ -23,7 +23,7 @@ module Mongoid def set_sort_number if self.new? && self.sort_number.nil? last_record = self.class.desc(:sort_number).first - if last_record + if last_record.sort_number self.sort_number = (last_record.sort_number + 10) / 10 * 10 else self.sort_number = 10