TL;DR —
Named Scopes are a subset of a collection and are lazy loaded. They are used when you do not have extra processing to perform on the retrieved data. Scope is a nice utility and helps keep our codes clean readable and simple. Let's see an example of scope chaining to build complex queries like this: User.confirmed.name('Nonso') This is a very simple example. The class file will look like this. The defined scopes above will be chained like:glyglyUser.confirmed('nonso')
[story continues]
Written by
@Nonso
Software Developer @Bitsfield Tech
Topics and
tags
tags
software-development|latest-tech-stories|coding|development|learning|learning-to-code|ruby
This story on HackerNoon has a decentralized backup on Sia.
Transaction ID: diRFqc5-LGIVle-v5eGg-QVijy-us4waU5uacLoOIW8
