1

I am trying to send an email to people when they do a payment through my site. I am able to generate the attachment and send it along with the emails.

I need my application flow to be like this :

Generate attachment -> Send with email -> Send the attachment to Google Drive

The first and second steps are done. I am having some issues with the third step. For Google Drive, I have made a separate module using the Google APIs and it is working nicely.

The issue I am having is with passing the pdf object to the Functions declared in Drive from my ActionMailer. Instead of passing the pdf, the function is sending this Object.

ActionMailer::Base::NullMail:0x0x0x(something)

The Mailer by default only returns ActionMailer objects, is there any way I can override it to return the PDF which I generated in my Mailer? If there is not, what are some other ways I can do it?

AkshatP
  • 544
  • 4
  • 14
  • Could you share some code? – bo-oz Jul 24 '18 at 06:36
  • Some time generating PDF need too many time. Doing that twice is not the better solution. Move generator from mailer to controller action that invokes mailer action and sending PDF to google drive. – Leo Jul 24 '18 at 06:50

2 Answers2

0

You can fetch the file path from ActionMailer objects or database and manipulate the file directly in the third step.

0

I have solved the issue and updating the answer so others could benefit.

I was able to implement it through importing the render function from the ActionController itself.

Now from the view object I can just do view.render and perform the same parameters. I am using Rails 4, but as some people have told me this functionality has been simplified in Rails 5.

I used this code from here : Rails: Render view from outside controller

view = ActionView::Base.new(ActionController::Base.view_paths, {})
view.render(file: 'template.html.erb')
AkshatP
  • 544
  • 4
  • 14