Undefined Method with CanCan, Devise and STI roles

匆匆过客 提交于 2019-12-12 06:07:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!