From 707ce0beeff88e0d9250f5390b0d0559e82cbed9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 23 Feb 2012 13:07:27 +0000 Subject: [PATCH] Preserve uploaded files when on news. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8942 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/news_controller.rb | 2 ++ app/views/news/_form.html.erb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 308497610..9d55f08b3 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -69,6 +69,7 @@ class NewsController < ApplicationController def create @news = News.new(:project => @project, :author => User.current) @news.attributes = params[:news] + @news.save_attachments(params[:attachments]) if @news.save attachments = Attachment.attach_files(@news, params[:attachments]) render_attachment_warning_if_needed(@news) @@ -83,6 +84,7 @@ class NewsController < ApplicationController end def update + @news.save_attachments(params[:attachments]) if @news.update_attributes(params[:news]) attachments = Attachment.attach_files(@news, params[:attachments]) render_attachment_warning_if_needed(@news) diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index 410df0e99..a0d2167a9 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -3,7 +3,7 @@

<%= f.text_field :title, :required => true, :size => 60 %>

<%= f.text_area :summary, :cols => 60, :rows => 2 %>

<%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit' %>

-

<%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %>

+

<%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form', :locals => {:container => @news} %>

<%= wikitoolbar_for 'news_description' %> -- 2.39.5