DEV Community

stuxnat
stuxnat

Posted on

1

Devise Gem

In my previous post, I mentioned the Devise gem, which handles the user authentication process in Rails. It simplifies the process in several ways: it generates the necessary controllers for user login and sessions, creates forms for user sign up/log in, and handles the encryption process with bcrypt, eliminating the need to salt and hash passwords yourself. The Devise gem also provides compatibility with other user authentication methods like OAuth, so the user would have the option to log in through a third party. This gem is great for streamlining the user authentication process and ensuring app security.

In this post, I want to go through set up with the gem!

Setting up:
Add gem devise to your Gemfile and run bundle install

Run rails g devise:install

Creating the User Model
Run rails g devise user and rake db:migrate

Voila! This gem will generate the controller for user log in.

To generate views run rails g devise:views

To work with Devise routes, add to routes.rb: devise_for :MODELNAME where MODELNAME is the name of the model you want to create the route for.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay