Ruby on rails 不能让cancancan与Desive合作

Ruby on rails 不能让cancancan与Desive合作,ruby-on-rails,ruby,devise,cancancan,Ruby On Rails,Ruby,Devise,Cancancan,我已经设计好了正确的设置和工作。Rolify似乎一切正常。坎坎坎似乎安装正确 当我在视图中执行此操作时 <% if user_signed_in? %> <% if current_user.has_role? "admin" %> User is signed in <% else %> User is NOT signed in <% end %> user.rb是 class User < ActiveReco

我已经设计好了正确的设置和工作。Rolify似乎一切正常。坎坎坎似乎安装正确

当我在视图中执行此操作时

<% if user_signed_in? %>
  <% if current_user.has_role? "admin" %>
    User is signed in
  <% else %>
   User is NOT signed in
 <% end %>
user.rb是

class User < ActiveRecord::Base

devise :avatarable, :database_authenticatable, :registerable,
    :recoverable, :rememberable, :trackable, :validatable
devise :avatarable, :omniauthable, omniauth_providers: [:facebook]
rolify

etc. 

etc.
我得到=>真的


我是不是遗漏了一些显而易见的东西?我到处都查过了,没办法弄清楚。

我要补充一点,如果我以注销用户或非管理员用户的身份进入categories/xxxx/edit,我仍然可以查看和编辑所有内容。您是否授权控制器操作(加载和授权资源)以及查看视图中的功能()?看,谢谢你,先生。这很有魅力。我一直在关注《坎坎坎,rolify&Deave》的教程,这是图坦卡蒙所缺少的一部分。
class User < ActiveRecord::Base

devise :avatarable, :database_authenticatable, :registerable,
    :recoverable, :rememberable, :trackable, :validatable
devise :avatarable, :omniauthable, omniauth_providers: [:facebook]
rolify

etc. 

etc.
class Category < ActiveRecord::Base
  extend FriendlyId

  resourcify
end
user.has_role? :admin