ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

error 500 when uploading a new file to an existing document (Bug #1008)

Added by Matthieu Robillard at 2012-05-03 09:47 am. Updated at 2012-05-19 07:32 pm.

Status:Closed Start date:2012-05-03
Priority:Normal Due date:
Assignee:- % Done:


Target version:3.2.0
Remote issue URL: Affected version:


This is with ChiliProject 3.1.0.d61ad0130 (MySQL)

Processing DocumentsController#add_attachment (for XXX.XXX.XXX.XXX at 2012-05-03 11:38:53) [POST]
  Parameters: {"commit"=>"Add", "action"=>"add_attachment", "authenticity_token"=>"XXXXXXXXXXXXXXXXXXXXXXXX", "id"=>"29", "controller"=>"documents", "attachments"=>{"1"=>{"file"=>#<File:/tmp/RackMultipart20120503-23495-19g45wf-0>, "description"=>""}}}

NoMethodError (undefined method `container' for [:unsaved, []]:Array):
  app/controllers/documents_controller.rb:88:in `add_attachment'
  passenger (3.0.7) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
  passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.7) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
  passenger (3.0.7) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
  passenger (3.0.7) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
  passenger (3.0.7) lib/phusion_passenger/utils.rb:479:in `safe_fork'
  passenger (3.0.7) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:180:in `start'
  passenger (3.0.7) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
  passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
  passenger (3.0.7) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
  passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
  passenger (3.0.7) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
  passenger (3.0.7) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
  passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
  passenger (3.0.7) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.7) helper-scripts/passenger-spawn-server:99

Rendering /srv/http/chiliproject/public/500.html (500 Internal Server Error)

Associated revisions

Revision 1d3cdf1f
Added by Felix Schäfer at 2012-05-18 10:45 pm

Correct email sending on attachment to document #1008


Updated by Robert Mitwicki at 2012-05-06 07:43 pm

I can confirm that. I have the same problem

Updated by Gregor Schmidt at 2012-05-18 07:52 pm

Thanks for taking the time to report and confirm this bug.

I have spent some time to look into it. Below are some hints for the Chili maintainers, so they may save some minutes.

To reproduce the problem, you need to enable email notifications for Document added. It was introduced by the "one mail per recipient" feature. There seems to be no test case which covers adding an attachment to document. The diff below seems to fix the problem.

 1diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents
 2index 4356ea0..eb5799d 100644
 3--- a/app/controllers/documents_controller.rb
 4+++ b/app/controllers/documents_controller.rb
 5@@ -85,7 +85,7 @@ class DocumentsController < ApplicationController
 7     if attachments.present? && attachments[:files].present? && Setting.notified
 8       # TODO: refactor
 9-      attachments.first.container.recipients.each do |recipient|
10+      @document.recipients.each do |recipient|
11         Mailer.deliver_attachments_added(attachments[:files], recipient)
12       end
13     end

Updated by Holger Just at 2012-05-18 08:20 pm

Thanks for researching that. We're going to include this into 3.2.0

  • Target version set to 3.2.0
  • Status changed from Open to Ready for review

Updated by Felix Schäfer at 2012-05-18 08:48 pm

Added a test and pushed Gregor's solution in 1d3cdf1, thanks a lot!

  • Status changed from Ready for review to Closed

Updated by Gregor Schmidt at 2012-05-19 07:32 pm

@Felix: Great. Thanks for writing a proper test.

@Matthieu, @Robert: If you do not want to update to the master branch of ChiliProject, you may also just deactivate email notifications for "Document added". This way you won't get notifications, but at least you are able to add files to attachments.


Also available in: Atom PDF