From 8f24aa6c676b90f125adc9bf75ecc1cbdaf7a379 2012-02-23 13:10:51 From: Jean-Philippe Lang Date: 2012-02-23 13:10:51 Subject: [PATCH] Preserve uploaded files when on documents. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8944 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 3f6c949..262088e 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -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 diff --git a/app/views/documents/_form.html.erb b/app/views/documents/_form.html.erb index 600bf66..b5b5fa4 100644 --- a/app/views/documents/_form.html.erb +++ b/app/views/documents/_form.html.erb @@ -10,6 +10,6 @@ <% if @document.new_record? %>
-

<%= render :partial => 'attachments/form' %>

+

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

<% end %>