Ruby On Rails - Send confirmation emails for users who sign up to your app

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys so today you are going to learn how to set up on confirmation email with device and race itself so here inside the app so here I can register a new account click on sign up back to the terminal itself you see that we have sent an email ok so we get you the message sent mail and the email address we have used and then also from where the email was sent from and then subjects to confirm the instructions confirmation instructions to finally activate the account so if I go to my email account here you see that we have now here an email with the email address that the email was sent from and then we also have your message we come and email that we have used and then you can confirm to account your email Fuji link below and then a link to confirm the account let's go back to our app and say users sign in let's try to sign in without confirming the email so now we get the message you have to confirm your email address before continuing so that's how you can confirm my account and so we get now the message your email address has been successfully confirmed and when I click now on login everything works ok so let's get started alright so to get started let's CD to your desktop raise new and I have to specify my version that I want to use so 5 point to point you and then Ana score so I have it also installed the beta of the Year race version 6 and Robbie environment will always take by default the newest version that you have installed so for this surgery I don't want to use the beta but the new version five point two point two and that's how you can specify this just in case you were wondering how to do that and now we need to add of course new and then mailer and device which is the name of the app and you can name your app whatever you want you whatever you like to call it or name it and then that's CTV and to my device and let's open up the text editor and then inside the campfire I want first of all specified he asked you a light version here quickly and I do this because there's lately but going on that some people get and I actually was able to fix the problem however for some reason it came back again so we definitely look into that and we'll probably do also a tutorial about that all right and then let's add your also device so with that we can run bundle install and once that's finished we also need to run rest G device installed okay so if you have watched some of my other tutorials you probably notice that we always copy the first line here will show up in just a moment or say that we need to add destroy development RB file so you might have been wondering what this is actually doing what this actually does so inside the vlog on RB let's paste it and let's talk about this quickly because now it's a great time to talk about that so all this does is set up the action mailer default URL option and set it through a host and a port in our case locust and the deported 3,000 so what this does is it makes us able to send emails from our development environment that's why we have to add that CD development rb5 so without that we will need to deploy our app and then tasks for example D a function to send emails from the production environment which is something we don't want okay so with that we are able to do that inside the development environment let's copy also here the classes and paste them quickly inside the app HTML Irby between body and yield like so and now we're good to go so let's create our device user model raise G device user hit enter and I will close everything inside the text editor and then let's go to DB my grade and here we have now our users migration file and let's go down here where it says come from Abel and let's uncomment this year so these are just four columns the first one is obviously the confirmation totin then we have the daytime confirmed at the day time confirmation sent and and then also the string unconfirmed email okay so we could add these later on as well but it makes it's actually much easier to simply uncomment this immediately before you run your migration so if there we can say raised to be my grade so this word generator or schema or before in just a moment with our users table in it and the attributes that we have uncomment it so confirmation token confirm the add confirmation sent add an unconfirmed email all right let's go also to the user RB file and make sure to add the module confirm able and so we can also add all our modules so definitely look into that like I always say it's worked it on to learn device because it comes with pretty much everything you need to get started and as you can see we can also and it's also really easy to customize it alright now let's close everything one more time and let's go to the device RB file and here where it says the config meta Center we can specify the email that we want to display once we send an email to a user so this way we obviously then the email that the user sees worthy may came from or has been sent it from so here we can say for example infrared awesome IO and obviously you would normally add for the name of your project or app that we are pretty much ready to go for this tutorial I will use SendGrid so you can sign up for free you get like 40,000 emails I think for the first month and then 100 emails per day for per month for free so simply sign up create an new account and then you will be probably redirected hugely guide path if not something go to absent grid comm it does comment and guide and then click here on start to integrate web api or smtp relay we want to choose the smtp relay which gives us basically just some basic informations to set up server and deport they also have a guide on send great dot-com docs for developers sending email and then Robin trace and we don't need here anything except the depart where they set up the action weather so let's copy this and you can either we type that or simply go to the tweet page here itself and then copy this and so with that let's go to the environment RB file and here and pasted it obviously we need to change the your Sun current username to the username we have used once we register and you account in my case that's just random user and obviously I just create a new account for this tutorial for a password you want to use the password that you have used for your account itself so no API key whatsoever just your password I want recorders obviously so I will add the password and then start recording again alright so I have added the password as well and so we are pretty much ready to go so let's start at the server and let's go to Locust users then sign up and then obviously we need to use an email we have access to click on sign up and you see it takes a little bit longer than normally and back and here inside our terminal we have the messers sent me through the in address that we have used and then we also get your email address we have from where the email has been centered from so this is in the info and also my Oh may address that we have specified inside device are being as you can see and then also again to who the email was sent to and then we get here a subject confirmation instructions and then preview of the email itself and all of that is pretty much coming from device itself so you can customize that if you want to but we're not do this first tutorial because we focus on the main part to confirm the email okay so with that let's go to our to the email here I have so inside the email account I have not the email and as you can see it's from the it was sent from info at also on IO and then we have Wickham and the email address we have used and then the message you can confirm your account you may fruity link below and then leaked so before we click that let's go back to your app and let's try to sign in without clicking on that so if I try to sign in now you see that we get now the message you have to confirm your email address before continuing so this all working and if I click on confirm my account this will then finally work we get another message your email address has been successful and then I can of course sign in and everything is working just nicely we can also for example go to race see and then get the first user by saying you equals to use it first and then we can for example I get the confirmation token or we can get the confirmed at daytime and pretty much everything as that we have added once we uncommented the migration the confirm able columns here okay all right so that would be best kids I hope you learned a lot I haven't been uploading lately anything to my youtube channel simply because I was working on my personal project they will announce you're on my youtube channel where soon and you I hope you learned a lot and thanks for watching [Music] [Music] you
Info
Channel: CodeCampBase
Views: 8,368
Rating: undefined out of 5
Keywords: Ruby On Rails, Rails ActionMailer, Rails SendGrid, SendGrid, Devise Email Confirmation, Ruby On Rails Devise, Mackenzie Child Rails, Web Development, Javascript, Ruby, Python, NodeJS, Stripe, Rails confirmation token, Rails API, Django, Laravel
Id: sVJRkTxqlSQ
Channel Id: undefined
Length: 11min 8sec (668 seconds)
Published: Thu Mar 21 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.