From 3bfaa20c057f97c25d4f8b68334bd4ff0f499887 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 26 Dec 2006 17:10:05 +0000 Subject: [PATCH] fixed: unable to attach a file when creating an issue ("attachment: invalid" error) git-svn-id: http://redmine.rubyforge.org/svn/trunk@122 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e4a47d3d1..85c644d23 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -204,12 +204,14 @@ class ProjectsController < ApplicationController @issue.attributes = params[:issue] @issue.author_id = self.logged_in_user.id if self.logged_in_user # Multiple file upload + @attachments = [] params[:attachments].each { |a| - @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0 + @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0 } if params[:attachments] and params[:attachments].is_a? Array @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) } - @issue.custom_values = @custom_values + @issue.custom_values = @custom_values if @issue.save + @attachments.each(&:save) flash[:notice] = l(:notice_successful_create) Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled? redirect_to :action => 'list_issues', :id => @project