Authentication with Devise and CanCanCan in Rails 8 · James Hibbard

21-Jun-2025 63
This is a tutorial on how to set up authentication (verifying who you are) and authorization (what you’re allowed to do) in a Ruby on Rails app using Devise and CanCanCan. We’ll use Rails 8 and Ruby 3.4, and build everything locally—no external auth services required. The code for this tutorial is on GitHub: https://github.com/hibbard-eu/authentication-with-devise-and-cancancan Note: this post was updated on 7th June, 2025 to use the latest versions of Ruby, Rails, Devise, and CanCanCan..
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle