Avoid nil.

This commit is contained in:
bootstraponline
2012-05-22 23:03:23 -06:00
parent ac41ed629e
commit c0e35b0126
+10 -4
View File
@@ -14,13 +14,19 @@ module Precious
end
def author
return DEFAULT_AUTHOR unless @page.version
@page.versions.first.author.name
pagev = @page.version
return DEFAULT_AUTHOR unless pagev
first = @page.versions.first
author = first == nil ? pagev.author : first.author
author.name
end
def date
return Time.now.strftime(DATE_FORMAT) unless @page.version
@page.versions.first.authored_date.strftime(DATE_FORMAT)
pagev = @page.version
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
def editable