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

You Might Also Like
Full Control for Complex IT - Try PRTG Now Icon
Full Control for Complex IT - Try PRTG Now

Gain deeper insights and proactive alerts for your entire network. PRTG empowers you to optimize uptime and prevent costly outages.

As an IT monitoring expert, you need more than basic alerts - you need actionable data and full transparency. PRTG gives your team a single pane of glass for all systems, devices, and applications, with customizable dashboards and granular user management. Detect issues before they escalate, automate reporting, and ensure compliance with SLAs. PRTG’s scalable engine and advanced analytics help you optimize resources, reduce manual effort, and keep your organization running smoothly. Take control of your IT landscape and make smarter decisions with real-time, enterprise-grade monitoring.
Activate Your PRTG Trial Today
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