From 435a634ac7183138d24f84784193e8c9e2b1ce06 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 23 Feb 2012 13:02:35 +0000 Subject: [PATCH] Preserve uploaded files when creating a forum topic. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8940 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/messages_controller.rb | 12 +++++++----- app/views/messages/_form.html.erb | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 1db3440e8..2a5571bb1 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -60,11 +60,13 @@ class MessagesController < ApplicationController @message.locked = params[:message]['locked'] @message.sticky = params[:message]['sticky'] end - if request.post? && @message.save - call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) - attachments = Attachment.attach_files(@message, params[:attachments]) - render_attachment_warning_if_needed(@message) - redirect_to :action => 'show', :id => @message + if request.post? + @message.save_attachments(params[:attachments]) + if @message.save + call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) + render_attachment_warning_if_needed(@message) + redirect_to :action => 'show', :id => @message + end end end diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index b3b0e130e..2ab04b2fb 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -24,5 +24,5 @@

<%= l(:label_attachment_plural) %>
-<%= render :partial => 'attachments/form' %>

+<%= render :partial => 'attachments/form', :locals => {:container => @message} %>

-- 2.39.5