Fix sortable when there's no record
This commit is contained in:
parent
96fc5ceea3
commit
c1bd135595
|
@ -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.sort_number
|
||||
if last_record && last_record.sort_number
|
||||
self.sort_number = (last_record.sort_number + 10) / 10 * 10
|
||||
else
|
||||
self.sort_number = 10
|
||||
|
|
Reference in New Issue