30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/models/resource_export_file.rb', line 30
def export!
transition_to!(:started)
role_name = user.try(:role).try(:name)
tsv = Manifestation.export(role: role_name)
file = StringIO.new(tsv)
file.class.class_eval { attr_accessor :original_filename, :content_type }
file.original_filename = 'resource_export.txt'
self.resource_export = file
save!
transition_to!(:completed)
mailer = ResourceExportMailer.completed(self)
send_message(mailer)
rescue => e
transition_to!(:failed)
mailer = ResourceExportMailer.failed(self)
send_message(mailer)
raise e
end
|