CanCan不允许动作但允许html?

时间:2014-03-07 00:27:57

标签: ruby-on-rails cancan

出于某种原因,对于未登录的用户,此代码显示html,但一旦点击删除,CanCan就不允许该操作。

  <% if can? :destroy, @boat %>
    <%= link_to "", boat, method: :delete, data: { confirm: "You sure?" } %>
  <% end %>

如何阻止HTML显示???

  def initialize(user)
       user ||= User.new
       if user.admin? || user.email = 'test@test.io'
         can :manage, :all
       elsif user.manager?
         can :read, Boat
         can [:create, :read, :update], User
       else
         can :read, Boat
         can :create, User      
       end
  end

1 个答案:

答案 0 :(得分:0)

该应用程序仍然检测到我的电子邮件,即使在注销并因此授予我管理员权限时也是如此!

不确定这是怎么回事......