ryanb/cancan — Issue #563: Already have an AR ability model....
Author: cj
Created: 2012-02-24 16:26:33+00:00
State: open

I already have an AR ability model... is it ok to just do this?

```ruby

class Ability < ActiveRecord::Base
include CanCan::Ability

#
# => Associations
#

has_many :permissions, as: :record
has_many :users, through: :permissions

def initialize(user = {})
# Define abilities for the passed in (current) user. For example:
#
# if user
# can :access, :all
# else
# can :access, :home
# can :create, [:users, :sessions]
# end
#
# Here if there is a user he will be able to perform any action on any controller.
# If someone is not logged in he can only access the home, users, and sessions controllers.
#
# The first argument to `can` is the action the user can perform. The second argument
# is the controller name they can perform that action on. You can pass :access and :all
# to represent any action and controller respectively. Passing an array to either of
# these will grant permission on each item in the array.
#
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
end
end
```