fix page model assign_page_number method for empty database

This commit is contained in:
manson 2014-08-19 12:17:00 +08:00
parent 3609fab32a
commit 3f15d8102c
1 changed files with 7 additions and 5 deletions

View File

@ -33,12 +33,14 @@ class Page
def assign_page_number
parent_page = self.parent_page
if parent_page.child_page.count == 0
number = 0
else
number = parent_page.child_page.max(:number) + 1
if !parent_page.nil?
if parent_page.child_page.count == 0
number = 0
else
number = parent_page.child_page.max(:number) + 1
end
self.number = number
end
self.number = number
end
def parent_pages