我有以下警告:
DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead.
以下是带范围
的行products = ((params.nil? || params[:search].blank?) ? products.scoped : products.filter_with_criterias(params[:search].split(" "), options))
products = ((params.nil? || params[:state].blank?) ? products.scoped : products.where(state: params[:state]))
简单的改变产品.scoped到products.all我收到
Failure/Error: products = ((params.nil? || params[:state].blank?) ?
products.all : products.where(state: params[:state]))
NoMethodError:
undefined method `all' for []:Array
答案 0 :(得分:0)
看起来products
已经是一个数组了,所以你应该可以在没有products
的情况下使用.all
:
products = ((params.nil? || params[:state].blank?) ? products : products.where(state: params[:state]))