Upgrading to 1.5
Clone this wiki locally
This document explains what's new in CanCan 1.5. If you are just getting started with CanCan, first check out the README.
A Rails 3 generator has been added for creating the
Ability class when starting out with CanCan. After adding and installing the
cancan gem, run the generator with this command.
rails g cancan:ability
Comments are included in the generated file with more information on using the Ability class.
Mongoid and DataMapper Support
There is improved support with
DataMapper. They now work with Fetching Records. This also means you can use their query syntax in the
can hash conditions.
# in Ability can :read, Article, :priority.lt => 5
CanCan will handle this behavior automatically, just be certain to add the Mongoid or DataMapper gem before CanCan in the Gemfile.
A great way to contribute to CanCan is to create a model adapter for other ORMs. See mongoid_adapter.rb for an example. Specs should also be included. See spec/README for running specs for specific adapters.
Skip Loading and Authorizing
Three new methods have been added to the controller:
skip_authorize_resource. Each of these can be used to skip either the loading or authorization behavior in CanCan. You can pass
:except option to either one to specify which actions to skip. For example.
class ProjectsController < ApplicationController load_and_authorize_resource skip_load_resource :only => :index end
You can optionally pass the name of the resource as the first argument just like you can in
Special thanks to everyone who helped contribute to this release. See the issue tracker for the history.