Authentication in ruby on rails

Authentication in ruby on rails

Hello Friends. Till now we have seen to setup a basic application and applying validations in previous articles. Now lets implements the authentication in our application.

For authentication, we will be implementing devise gem. This gem is rich of modules related to authentications, such as:

  • Registerable
  • Recoverable
  • Rememberable
  • Confirmable
  • Trackable and many more...

Add following in Gemfile and run bundle install

gem 'devise'        

After running bundle install you can see changes in models/user.rb file

No alt text provided for this image

Modify the routes.rb file as follow:

No alt text provided for this image

Now when you run the server and visit http://localhost:3000/ , you will be redirected to sign in page as shown in following screenshot:

No alt text provided for this image

On clicking signup link you will be able to navigate to signup page as shown below:

No alt text provided for this image

Similarly you can try to access forgot password page and also try to sign up and sign in.

Further we will be aiming to add some design and authorisation to the records that we will add. Till then enjoy and cheers!

To view or add a comment, sign in

More articles by Vishal Malukani

  • Ruby on Rails Validations

    In continuation of previous article, where we created a basic rails application, let continue to add validations to the…

    1 Comment
  • Ruby on Rails app from scratch

    Ruby on Rails framework has numerous advantages. One of them is faster development of websites.

    2 Comments

Explore content categories