You have a webshop and you want to display all products that are on sale.
Let’s asume your products table has a column named sale and is of the type boolean.
In the product model you set the scope like this:
Now in the desired controller#action you can set the products that are on sale like this:
Check out the Rails docs for more info about scopes.