paint-brush
How To Use Named Scopes In Railsby@Nonso
338 reads
338 reads

How To Use Named Scopes In Rails

by Nonso2mOctober 19th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

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

Company Mentioned

Mention Thumbnail
featured image - How To Use Named Scopes In Rails
Nonso HackerNoon profile picture
Nonso

Nonso

@Nonso

Software Developer @Bitsfield Tech

About @Nonso
LEARN MORE ABOUT @NONSO'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Nonso HackerNoon profile picture
Nonso@Nonso
Software Developer @Bitsfield Tech

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite