CanCan is an authorization library for Ruby on Rails that helps manage user permissions in a clean and consistent way. It centralizes all authorization logic in a single Ability class, where you define what actions each type of user can or cannot perform on different resources. Developers then use helpers like authorize! in controllers or can? in views to enforce those rules without scattering permission logic across the application. It supports defining permissions using conditions, allowing granular access based on attributes like ownership or role. Because it abstracts authorization cleanly, applications stay easier to read, test, and maintain as business rules evolve. Though no longer actively maintained in its original form, CanCan inspired forks and successors (such as CanCanCan) that continue to be widely used in Rails projects.

Features

  • Define user permissions in a single Ability class rather than scattering logic across controllers and views
  • Helper methods in controllers and views like can?, cannot?, authorize! to test or enforce permissions
  • load_and_authorize_resource support: automatically loading resources and checking abilities for RESTful controllers
  • Ability to rescue from unauthorized access exceptions and handle accordingly (redirect, flash message, etc.)
  • Checks for authorization in all actions, with a mechanism to skip authorization where needed, or ensure it's always checked with check_authorization
  • Integration with Rails conventions (current_user, filters, controller/view helpers) so minimal boilerplate required in Rails apps using it

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

MIT License

Follow CanCan

CanCan Web Site

Other Useful Business Software
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of CanCan!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Ruby

Related Categories

Ruby Libraries

Registered

2025-09-17