You can use has_secure_password provided by ActiveModel in Rails 4.x to implement a simple authentication system. Read Authentication from Scratch articles to learn how:
Login and Logout
Email Validation and Testing using Rspec
For Rails 5, here is the sample project that has signup, login and logout features.