Unable to view mailing lists and Rails mailings in subfolders

I have a mail program that I see in my journal sent, but the body of the letter does not contain anything from the view of the mail program.

This is because I put things in subfolders, and I tried to use :template_pathin my function mail, but to no avail.

application / senders / marketing / marketing_mailer.rb

class Marketing::MarketingMailer < ActionMailer::Base

    require 'mail'
    address = Mail::Address.new "test@example.com" # ex: "john@example.com"
    address.display_name = "Text" # ex: "John Doe"
    # Set the From or Reply-To header to the following:
    address.format # returns "John Doe <john@example.com>"
    default from: address

    # Sends an email when someone fills out the contact form
    def contact(name, email, message)
        @name = name
        @email = email
        @message = message
        mail(:subject => "Test", :to => 'test@example.com', :reply_to => @email) # <== I've tried using :template_path => 'marketing', 'marketing/marketing_mailer', etc, but none worked.
    end
end

/app/views/marketing/marketing_mailer/contact.html.erb

<!DOCTYPE html>
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
  </head>
  <body>
    <p>Name: <%= @name %></p>
    <p>Email: <%= @email %></p>
    <p>Message: <%= @message %></p>
  </body>
</html>

I noticed that the developer has mailer views inside / views / devise / mailers / ... so I know this is possible, but I'm not sure how to do it.

+4
source share
4 answers

, , , template_path.

, , , , , . , .

+2

   class Marketing::MarketingMailer < ActionMailer::Base
   def welcome_email(user, email_body)
     mail(to: user.email,
     body: email_body,
     content_type: "text/html",
     subject: "Already rendered!")
   end
   end
+3

.html.erb, , . :

mail(:subject => "Test", :to => 'test@example.com', :reply_to => @email) do
  format.html
end

, , , , , .text.erb, - , .

EDIT1 ( ) , , , . , @message - , , . apidock, @variables . , .

EDIT2 ( , ) - - :

, . , , . , .

, .

Have you tried turning it off and on again?

+2
source

Have you tried mail with {: template_path => 'marketing / marketing_mailer ,: template_name =>' contact '}?

The template name probably expects the namespace in the file name somehow

+2
source

All Articles