From b976c9efd8d18a48646b52a665b8aecdb9b7e3b0 Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 17 Jun 2014 12:06:40 +0800 Subject: [PATCH] Fix show method display file tile and link title --- app/controllers/announcements_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index eac3588..1185236 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -58,8 +58,8 @@ class AnnouncementsController < ApplicationController announcement = Bulletin.can_display.find_by(:uid=>params[:uid]) tags = announcement.tags.map{|tag| { "tag" => tag.name } } rescue [] - files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => file.title } } rescue [] - links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => link.title } } rescue [] + files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title) } } rescue [] + links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] update_user = announcement.update_user.member_profile.name rescue "" { "tags" => tags,