From f811cfc34f9a0ede875a69d071c8c6346c463e46 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Fri, 11 Jul 2014 16:54:41 +0800 Subject: [PATCH] fixed nil condition error publication date --- app/controllers/journal_papers_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/journal_papers_controller.rb b/app/controllers/journal_papers_controller.rb index 788b092..4739304 100644 --- a/app/controllers/journal_papers_controller.rb +++ b/app/controllers/journal_papers_controller.rb @@ -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 }