From c56c0f411c577fe17b64fe33875cad5d75e34284 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Sat, 19 Jun 2010 03:54:17 +0000 Subject: Fix a nil error when a Project cannot save attachments. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3772 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/attachment.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c752e0e52..f05b35c77 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -150,7 +150,13 @@ class Attachment < ActiveRecord::Base :file => file, :description => attachment['description'].to_s.strip, :author => User.current) - a.new_record? ? (obj.unsaved_attachments << a) : (attached << a) + + if a.new_record? + obj.unsaved_attachments ||= [] + obj.unsaved_attachments << a + else + attached << a + end end end {:files => attached, :unsaved => obj.unsaved_attachments} -- cgit v1.2.3