##// END OF EJS Templates
fixed: unable to attach a file when creating an issue ("attachment: invalid" error)...
Jean-Philippe Lang -
r119:3bfaa20c057f
parent child
Show More
@@ -204,12 +204,14 class ProjectsController < ApplicationController
204 @issue.attributes = params[:issue]
204 @issue.attributes = params[:issue]
205 @issue.author_id = self.logged_in_user.id if self.logged_in_user
205 @issue.author_id = self.logged_in_user.id if self.logged_in_user
206 # Multiple file upload
206 # Multiple file upload
207 @attachments = []
207 params[:attachments].each { |a|
208 params[:attachments].each { |a|
208 @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
209 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
209 } if params[:attachments] and params[:attachments].is_a? Array
210 } if params[:attachments] and params[:attachments].is_a? Array
210 @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]) }
211 @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]) }
211 @issue.custom_values = @custom_values
212 @issue.custom_values = @custom_values
212 if @issue.save
213 if @issue.save
214 @attachments.each(&:save)
213 flash[:notice] = l(:notice_successful_create)
215 flash[:notice] = l(:notice_successful_create)
214 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
216 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
215 redirect_to :action => 'list_issues', :id => @project
217 redirect_to :action => 'list_issues', :id => @project
General Comments 0
You need to be logged in to leave comments. Login now