Devise Gem — What is it?

David Caldwell
Nov 7 · 2 min read

What is Devise?

Devise is a Ruby on Rails Gem that takes away the hassle of creating a user and sessions controller for your application. With Devise, you can generate both user and sessions controller simultaneously, as well as views that allow users to sign in, sign out, and sign up immediately and that’s just the start.

What Else Does Devise Do?

After installation, Devise has a lot of built Methods and Modules that are available right away. Below i have mentioned some that will save developers a lot of time.

Devise Helpful Methods:

  • user_session — Returns meta data of the current user.
  • Current_User — Gives you access to the current user.
  • authenticate_user! — Checks database to see if the users information is correct.
  • user_signed_in? — If user is signed in, then do this…
  • user_signed_out? — If user is signed out, then do this…

Devise within you Model:

  • database_authenticatable — validates that a user enters a correct password, and it encrypts the said password, before saving it.
  • confirmable — ensures users confirm their accounts via email they . This is a defence against bots creating fake, but valid, users.
  • recoverable —Used if users have forgotten passwords.
  • registerable — allows users to sign up, and edit their login credentials.
  • rememberable — Using cookies, this is the functionality associated with the remember me? checkbox
  • trackable — Track users IP’s, logged in time, last time logged in, total number of times a user has logged in and more.
  • validatable — Makes sure user meets all your validations. The default are, password must be 6 characters and email must be an email.
  • lockable — limits the number of login attempts allowed before further access to a particular account is prohibited.
  • Omniauthable — Adds support for Omniauth provider, allowing log in through third-party providers like Facebook, Twitter, etc
  • Timeoutable — Logs a user out after a certain amount of time.

Devise Routes —

Devise automatically create routes for your Users Controller, which includes sign in, sign out, sign up and log out.

Devise — The Conclusion

After doing research and creating an application that uses Devise, I can honestly say that it is an amazing gem that plataformatec should receive a lot of credit for. However, I’m not saying it perfect but the things that aren’t perfect can be easily changed to your liking. People have also made basic Devise applications with their own spin that are available for free on github. (One as an admin portable that I need to check out very soon)

Hope this helpful and you get the chance to check out Devise in the near future.

Devise Links and Information

https://github.com/plataformatec/devise/wiki/Example-Applications

https://launchschool.com/blog/how-to-use-devise-in-rails-for-authentication

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade