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
This commit is contained in:
Jean-Philippe Lang 2006-12-26 17:10:05 +00:00
parent 58f8a23d58
commit 3bfaa20c05
1 changed files with 4 additions and 2 deletions

View File

@ -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