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

app/controllers/documents_controller.rb
app/views/documents/_form.html.erb

index 3f6c9497ef07bccff2202faeb4df2003b3f20949..262088ed2dddf30d135e84184f313e3621fffe0b 100644 (file)
@@ -52,8 +52,8 @@ class DocumentsController < ApplicationController
 
   def create
     @document = @project.documents.build(params[:document])
-    if request.post? and @document.save        
-      attachments = Attachment.attach_files(@document, params[:attachments])
+    @document.save_attachments(params[:attachments])
+    if @document.save
       render_attachment_warning_if_needed(@document)
       flash[:notice] = l(:notice_successful_create)
       redirect_to :action => 'index', :project_id => @project
index 600bf66ebf4e9128bb991a8ef0b2a261057fa346..b5b5fa4100f8d3fde90b6f98d04f685ec33c012f 100644 (file)
@@ -10,6 +10,6 @@
 
 <% if @document.new_record? %>
 <div class="box tabular">
-<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
+<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form', :locals => {:container => @document} %></p>
 </div>
 <% end %>