ability.rb
@Override
public void onBackPressed(){
super.onBackPressed();
}
index.html.erb
can :destroy, Business, Business.where(id: user.auth_ids)
如果用户字段auth_ids:[]包含业务ID,我想访问删除按钮 但是我得到了这样的错误
<% if can? :destroy, @business %>
<%= link_to 'delete', business_path(@business.id), method: :delete%>
<% end %>
任何人都可以告诉我导致问题的原因以及如何解决问题?
答案 0 :(得分:0)
当语法不正确时,似乎会发生这种情况。试试hash with your condition:
# ability.rb
can :destroy, Business, id: user.auth_ids
或block condition with your scope:
# ability.rb
can :destroy, Business, Business.where(id: user.auth_ids) do
#... additional logic
end