Step by step authentication with Devise in Ruby on Rails

Ruby on Rails, 2015-06-16 23:09:58 UTC

1. Preparing your gem

gem 'devise',: git => '',: branch => 'lm-rails-4-2'

2. Run the following command

$ bundle install

3. Install devise

$ rails g devise:install

4. Add the following line to /config/development.rb

config.action_mailer.default_url_options = {host: 'localhost', port: 3000}

5. Make sure to have root_url to "something" example:

root "posts # index"

6. If you want to add a notice on application.html.erb (according to the command rails g device: install)

<% If notice%>
<% = notices%> <% End%> <% If alerts%>
<% = alerts%> <% End%>

7. Generate devise user

$ rails g devise User

8. Run the following command to migrate the database

$ rake db:migrate

9. Generate view if you want to make changes to the form and other auth user. Run the following command;

$ rails g devise:views

10. Restart the server in order the devise run