summaryrefslogtreecommitdiffstats
path: root/app/models/attachment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/attachment.rb')
-rw-r--r--app/models/attachment.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 221618c6a..c752e0e52 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -139,11 +139,9 @@ class Attachment < ActiveRecord::Base
# Returns a Hash of the results:
# :files => array of the attached files
# :unsaved => array of the files that could not be attached
- # :flash => warning message
def self.attach_files(obj, attachments)
attached = []
unsaved = []
- flash = nil
if attachments && attachments.is_a?(Hash)
attachments.each_value do |attachment|
file = attachment['file']
@@ -152,13 +150,10 @@ class Attachment < ActiveRecord::Base
:file => file,
:description => attachment['description'].to_s.strip,
:author => User.current)
- a.new_record? ? (unsaved << a) : (attached << a)
- end
- if unsaved.any?
- flash = l(:warning_attachments_not_saved, unsaved.size)
+ a.new_record? ? (obj.unsaved_attachments << a) : (attached << a)
end
end
- {:files => attached, :flash => flash, :unsaved => unsaved}
+ {:files => attached, :unsaved => obj.unsaved_attachments}
end
private