· 9 years ago · Sep 03, 2016, 12:04 PM
1Setting up Devise Rails Gem
2==
3
4Add gem to Gemfile
5--
6Add this line to your Gemfile:
7
8`gem 'devise'`
9
10Install Devise Files
11--
12From the terminal, run these commands:
13
14```
15bundle install
16rails generate devise:install
17rails generate devise user
18rails generate devise:views
19```
20
21Make User Confirmable
22=====================
23Open user.rb and add ":confirmable" to the devise line.
24
25Modify migration
26================
27Open the new migration file generated by devise and uncomment the lines under the "Confirmable" area
28
29Set up outbound email
30=====================
31If you don't have an gmail account you want to use for sending emails, make one.
32
33Then you can put this boiler plate code in development.rb:
34
35```
36development.rb
37config.action_mailer.raise_delivery_errors = true
38config.action_mailer.delivery_method= :smtp
39config.action_mailer.perform_deliveries = true
40config.action_mailer.default_url_options = {host: 'localhost', port:3000}
41config.action_mailer.smtp_settings = {
42 address: "smtp.gmail.com",
43 port: 587,
44 domain: "gmail.com",
45 authentication: "plain",
46 enable_starttls_auto:true,
47 user_name: "<username>",
48 password: "<password>"
49}
50```
51
52For username, just put the account part before the "@" symbol. If my email is "dude@gmail.com", I'll just put "dude" here.
53
54Configure Mailer Sender
55==
56In config/initializers/devise.rb, change the "config.mailer_sender" item to the email account you used above. For example, "dude@gmail.com".
57
58Creating a new account
59==
60You 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
61
62You'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.
63
64Using Devise
65==
66TBD