Avoid nil.
This commit is contained in:
@@ -14,13 +14,19 @@ module Precious
|
|||||||
end
|
end
|
||||||
|
|
||||||
def author
|
def author
|
||||||
return DEFAULT_AUTHOR unless @page.version
|
pagev = @page.version
|
||||||
@page.versions.first.author.name
|
return DEFAULT_AUTHOR unless pagev
|
||||||
|
first = @page.versions.first
|
||||||
|
author = first == nil ? pagev.author : first.author
|
||||||
|
author.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def date
|
def date
|
||||||
return Time.now.strftime(DATE_FORMAT) unless @page.version
|
pagev = @page.version
|
||||||
@page.versions.first.authored_date.strftime(DATE_FORMAT)
|
return Time.now.strftime(DATE_FORMAT) unless pagev
|
||||||
|
first = @page.versions.first
|
||||||
|
date = first == nil ? pagev.authored_date : first.authored_date
|
||||||
|
date.strftime(DATE_FORMAT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def editable
|
def editable
|
||||||
|
|||||||
Reference in New Issue
Block a user