From 837c14739d7523267f36724c3c1ee1df098871c9 Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 24 Jun 2014 15:57:27 +0800 Subject: [PATCH] Fix preview with attatched file --- app/controllers/admin/announcements_controller.rb | 4 +++- app/controllers/announcements_controller.rb | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index c5811cf..98f14f5 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -88,8 +88,10 @@ class Admin::AnnouncementsController < OrbitAdminController file.bulletin_id = bulletin.id file.save else - file = BulletinFile.find(bulletin_file['id']).clone + org_file = BulletinFile.find(bulletin_file['id']) + file = org_file.clone file.bulletin_id = bulletin.id + file.file = org_file.file bulletin_file.delete('id') bulletin_file.delete('_destroy') file.update_attributes(bulletin_file) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index dbcde3a..b8980c5 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -61,7 +61,6 @@ class AnnouncementsController < ApplicationController 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 "" - # announcement.destroy if announcement.is_preview { "tags" => tags, "bulletin_files" => files,