fixed nil condition error publication date

This commit is contained in:
Saurabh Bhatia 2014-07-11 16:54:41 +08:00
parent ddd3a378f6
commit f811cfc34f
1 changed files with 2 additions and 1 deletions

View File

@ -17,6 +17,7 @@ class JournalPapersController < ApplicationController
def show
params = OrbitHelper.params
journal_paper = JournalPaper.find_by(uid: params[:uid])
publication_date = journal_paper.publication_date.to_date.strftime("%Y/%m/%d") rescue nil
files = journal_paper.journal_paper_files.map{|file| { "file_url" => file.journal_file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title) } } rescue []
{
"journal_paper_files" => files,
@ -34,7 +35,7 @@ class JournalPapersController < ApplicationController
"total_pages" => journal_paper.total_pages,
"keywords" => journal_paper.keywords,
"abstract" => journal_paper.abstract,
"publication_date" => journal_paper.publication_date.to_date.strftime("%Y/%m/%d"),
"publication_date" => publication_date,
"url" => journal_paper.url,
"note" => journal_paper.note
}