Add this line to your Gemfile:
gem 'devise'
From the terminal, run these commands:
bundle install
rails generate devise:install
rails generate devise user
rails generate devise:views
Open user.rb and add ":confirmable" to the devise line.
Open the new migration file generated by devise and uncomment the lines under the "Confirmable" area
If you don't have an gmail account you want to use for sending emails, make one.
Then you can put this boiler plate code in development.rb:
development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method= :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = {host: 'localhost', port:3000}
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: "plain",
enable_starttls_auto:true,
user_name: "<username>",
password: "<password>"
}
For username, just put the account part before the "@" symbol. If my email is "dude@gmail.com", I'll just put "dude" here.
In config/initializers/devise.rb, change the "config.mailer_sender" item to the email account you used above. For example, "dude@gmail.com".
You can check the routes that devise creates (by running rake routes from the command line). To create a new user, go to localhost:3000/users/sign_up
You'll have to put in an email address, a password of 6 characters or more, and confirm your password. Then check your email and you can confirm your account.
TBD