Home ActionMailer Class not getting inherited in Rails App
Reply: 0

ActionMailer Class not getting inherited in Rails App

user1388
1#
user1388 Published in June 23, 2018, 4:32 am

I am working on a Ruby on Rails 4.2.10 App with no views of the project structure. It is the backend logic in a Microservices architecture.

The problem I have here is the ActionMailer class is not getting inherited by the subclasses.

The emails were sent previously. Now, this same implementation is not working. Does this have anything to do with the Rails version? Please help.

application_mailer.rb

class ApplicationMailer < ActionMailer::Base
  default from: "from@example.com"
  layout 'mailer'
end

sample_mailer.rb

class SampleMailer < ApplicationMailer

    def  xlsx_email(email, xlsx, filename)
         mail.attachments[filename] = xlsx.read
         body = "The  report you requested is attached.\n\nThanks "
         mail(from: "noreply@sample.com", to: email, subject: "Report ", body: 
          body)
    end

end

The error I get is

NameError: undefined local variable or method 'mail' for SampleMailer:Class

When I tried using the mail and attachment method to call directly using ActionMailer::Base , it showed error

ActionView::MissingTemplate: Missing template sample_mailer/xlsx_email with "mailer". Searched in:* "sample_mailer"

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302727 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO