【发布时间】:2016-12-22 06:56:50
【问题描述】:
能力.rb
can :destroy, Business, Business.where(id: user.auth_ids)
index.html.erb
<% if can? :destroy, @business %>
<%= link_to 'delete', business_path(@business.id), method: :delete%>
<% end %>
如果用户字段 auth_ids: [] 包含企业 ID,我想访问删除按钮。
但是我遇到了这样的错误
CanCan::Error - The can? and cannot? call cannot be used with a raw sql 'can' definition.
谁能告诉我问题的原因以及如何解决?
【问题讨论】:
标签: ruby-on-rails cancan