Authentication with Devise

In this tutorial we will see how you can authenticate the RUBY on Rails application with Devise gem

Devise

Step 1
Add the following code to youe Genfile
gem 'devise'

Step 2
Next, you run the following command
rails generate devise:install
This will make your application ready for Device

Some setup you must do manually if you haven’t yet:

1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:

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

In production, :host should be set to the actual host of your application.

2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:

root to: “home#index”

3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:

<%= notice %>

<%= alert %>

4. You can copy Devise views (for customization) to your app by running:

rails g devise:views

Step 3
Now we will crate the User model
rails g devise user

Step 4
Then you can run the migrate command
db:migrate

This will generate following routes in your application and also devise_for :users will be added to congfig\routes.rb file

Where are your template files?

How about the template files for sign up, sign in etc? Where are they located?