问题
I have setup Devise with STI roles and also CanCan (and rails admin). I am trying to make CanCan work why my STI roles here is my ability.rb files
def initialize(user)
can :read, :all
if user and user.is_admin?
can :access, :rails_admin
can :manage, :all
end
I added this to my user.rb model
def is_admin?
true if self.type == Admin
end
That code is inside the class User < ActiveRecord::Base
When I test I get this error
undefined method `is_admin?' for true:TrueClass
What am I missing here?
Answer in comments
来源:https://stackoverflow.com/questions/9527298/undefined-method-with-cancan-devise-and-sti-roles