Ask A Question

Notifications

You’re not receiving notifications from this thread.

Get Email from DataBase for creating newsletter

Derek Levine asked in Rails

I am trying to create a newsletter, Ive followed this instructional video on how to save the information but I am confused on what to do from the end of the video,

https://www.youtube.com/watch?v=mavV5LH-Z40&feature=emb_title

After checking my console it seems that everything is being saved correctly im just wondering how to now get that information to the action mailer gem

Reply

Check out the Actionmailer guides: https://guides.rubyonrails.org/action_mailer_basics.html

If you had a LeadMailer that sent a new_lead email, it would be:

LeadMailer.with(lead: @lead).new_lead.deliver_later
Reply

So would it look something like this? I'm confused as to where the program takes the email from the database as there isn't a user defined.

class LeadMailer.with(lead: @lead).new_lead.deliver_later < ApplicationMailer
def welcome_email
mail(to: params[:user].email) do |format|
format.html { render layout: 'my_layout' }
format.text
end
end
end

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.