How to replace rails 3 Model.scoped by rails 4 Model.all -


i converting project rails 3 4.2. found scoped deprecated. me scoped confusing. current code in index controller below

@customers = customer.scoped @customers = customer.between(params['start'], params['end']) if (params['start'] && params['end']) 

so how can remove customer.scoped above code still keep same functionality??

as other articles suggested use all instead of scoped. tried this

@customers = customer.all @customers = @customers.between(params['start'], params['end']) if (params['start'] && params['end']) 

i not sure though if converted code okay or not.

have tried this

@customers = customer.where(nil) 

instead of

@customers = customer.scoped 

refer https://github.com/lassebunk/dynamic_sitemaps/pull/35


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -