Ans*_*son 6

执行Ransack搜索后,只需使用CanCan过滤结果.这是我的应用列出提供商的示例.

如果您的能力不使用积木,请使用accessible_by:

def index
  @search = Provider.sorted.search(params[:q])
  @providers = @search.result.accessible_by(current_ability)
end
Run Code Online (Sandbox Code Playgroud)

如果你的能力使用积木,你不能使用accessible_by:

def index
  @search = Provider.sorted.search(params[:q])
  @providers = @search.result.select{|p| can? :read, p}
end
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息和示例,请查看获取记录中的cancan wiki

希望有所帮助