Answer the question
In order to leave comments, you need to log in
How to attach a newly created excel file to a post?
There is a mailer in which an excel file is generated and attached to the mailing list, everything is like here:
https://github.com/caxlsx/caxlsx_rails#mailers
xlsx = render_to_string layout: false, template: "my_dir/export"
xlsx_base64 = Base64.encode64(xlsx)
attachment = {mime_type: Mime[:xlsx], content: xlsx_base64, encoding: 'base64'}
attachments["file.xlsx"] = attachment
class MyLog < ApplicationRecord
has_one_attached :xlsx_file
end
MyLog.create(
# xlsx - это то, что я выше создал. Возможно нужен xlsx_base64 или attachment
xlsx_file: xlsx
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question