Home DEPRECATION WARNING: Model.scoped is deprecated
Reply: 1

DEPRECATION WARNING: Model.scoped is deprecated

Yehor Chumak
1#
Yehor Chumak Published in 2017-11-30 13:08:20Z

I have the following warning:

 DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead.

Here are lines with scoped

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]))

After simple change products.scoped to products.all i am receiving

Failure/Error: products = ((params.nil? || params[:state].blank?) ? 
products.all : products.where(state: params[:state]))

NoMethodError:
  undefined method `all' for []:Array
seancdavis
2#
seancdavis Reply to 2017-11-30 16:32:02Z

It looks like products is already an array, so you should be able to just use products without the .all:

products = ((params.nil? || params[:state].blank?) ? products : products.where(state: params[:state]))
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.318434 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO