Create the Newsletter model:
model Newsletter name:string email:stringnewsletter.rb
Create the Newsletter controller:
controller Newsletters create
After that, change the create.html.erb view to the nex name. We will convert this file to and partial view which will be stored inside the Footer. The name will be _form.html.erb.
Change name file from: | To: |
|:———————————————––|:—————————————————| | app/views/newsletters/create.html.erb | app/views/newsletters/_form.html.erb |
After that set the routes:
routes.rb
Later on, we need to set the form we will use to save each mail:
_form.html.erb
And after that, insert on the footer:
_footer.html.erb
Now, install the -letter_opener- to can preview email in the default browser instead of sending it. This means you do not need to set up email delivery in your development environment, and you no longer need to worry about accidentally sending a test email to someone else’s address.
First add the gem to your development environment and run the bundle command to install it.
Gemfile
Then set the delivery method in the Development Environment:
development.rb
Now, create an Mailer Structure to manage the whole mailers which we will work. In terminal
UserMailer newsletter_mailer