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

ActionMailer Class not getting inherited in Rails App

user6378 Published in September 20, 2018, 1:16 pm

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.


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


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: 


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"

share|improve this question
  • Try replacing the first line of the xlsx_email method with attachments[filename] = xlsx.read – eugen Feb 9 at 15:34

1 Answer 1

active oldest votes
up vote 0 down vote
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO