From a3c66b1a6e0f090d7b3c1b13f8d01d5cb352a91f Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Wed, 2 Jul 2014 10:29:13 +0800 Subject: [PATCH] fixed file loop for jounral paper show --- app/models/journal_paper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index e16ec9f..86c94ba 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -95,9 +95,9 @@ class JournalPaper attribute_values = self.attributes.select{|k,v| v if (k.in?(["year","language","isbn","vol_no","issue_no","form_to_start","form_to_end","total_pages","keywords","abstract","publication_date","url","note"]) && v.present?)} localized_fields = {"paper_title" => self.attributes["paper_title"][I18n.locale], "journal_title" => self.attributes["journal_title"][I18n.locale]} authors = {"authors" => self.authors} - files = Hash.new - self.journal_paper_files.each do |f| files = {"file_link" => url_to_file(f.journal_file.url, f.title)} end - values = [attribute_values, localized_fields, authors,files] + files = {} + files = self.journal_paper_files.collect do |f| {f.title => url_to_file(f.journal_file.url, f.title)} end + values = [attribute_values, localized_fields, authors] + files values.inject(&:merge) end