Even if you mainly use Ruby on Rails to generate web pages, it sometimes is useful to be able to send an e-mail.
So, let’s build an example with minimal user management for a web shop that automatically sends an e-mail to the user when a new user is created, as shown here:
$ rails new webshop
$ cd webshop
$ rails generate scaffold User name email
$ rails db:migrate
For the user model, create a minimal validation in app/models/user.rb so that you can be sure that each user has a name and a syntactically correct e-mail address (see Listing 11-1).
class User < ApplicationRecord ...