]> source.dussan.org Git - redmine.git/commitdiff
Preserve uploaded files when creating a forum topic.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Feb 2012 13:02:35 +0000 (13:02 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Feb 2012 13:02:35 +0000 (13:02 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8940 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/messages_controller.rb
app/views/messages/_form.html.erb

index 1db3440e8acdd75409d94e19201ac5bb81623d14..2a5571bb1a211fe120995ce2d82b748b21299edb 100644 (file)
@@ -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
 
index b3b0e130efa0b31f47601d0e42238d4a16b9b520..2ab04b2fb20fd24a60397b4a73bb371fb8f431bd 100644 (file)
@@ -24,5 +24,5 @@
 <!--[eoform:message]-->
 
 <p><%= l(:label_attachment_plural) %><br />
-<%= render :partial => 'attachments/form' %></p>
+<%= render :partial => 'attachments/form', :locals => {:container => @message} %></p>
 </div>