28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/models/event_export_file.rb', line 28
def export!
role_name = user.try(:role).try(:name)
tsv = Event.export(role: role_name)
EventExportFile.transaction do
transition_to!(:started)
role_name = user.try(:role).try(:name)
self.event_export = StringIO.new(tsv)
self.event_export.instance_write(:filename, "event_export.txt")
save!
transition_to!(:completed)
end
mailer = EventExportMailer.completed(self)
send_message(mailer)
rescue => e
transition_to!(:failed)
mailer = EventExportMailer.failed(self)
send_message(mailer)
raise e
end
|