6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/active_admin/async_export/async_export_mailer.rb', line 6
def csv_export(admin_email, model_name)
controller = Kernel::qualified_const_get("Admins::#{model_name}sController").new
config = controller.send(:active_admin_config)
path = controller.send(:active_admin_template, 'index.csv')
csv_filename = controller.send(:csv_filename)
collection = controller.send(:scoped_collection)
app = ActiveAdmin.application
csv = render_to_string(file: path,
layout: false,
locals: {
active_admin_application: app,
active_admin_config: config,
collection: collection,
})
attachments[csv_filename] = csv
mail(to: admin_email,
subject: csv_filename,
body: 'See attached',
from: ActiveAdmin::AsyncExport.from_email_address)
end
|