Code Explainers
Code explainers tagged #scopes
ruby
class ProductsController < ApplicationController def index @products = Product .includes(:category, :brand)
Building a safe filterable product index in Rails
query objects
scopes
strong parameters
Intermediate
8 steps
ruby
module SoftDeletable extend ActiveSupport::Concern included do
How a soft-delete concern works in Rails
concerns
soft-delete
scopes
Intermediate
8 steps
ruby
class Article < ApplicationRecord belongs_to :author default_scope { where(deleted_at: nil) }
How scopes compose in Rails
scopes
query-composition
activerecord
Intermediate
9 steps
ruby
class Employee < ApplicationRecord validates :name, presence: true validates :salary, numericality: { greater_than: 0 }
How STI models share behavior in Rails
single-table-inheritance
inheritance
method-overriding
Intermediate
8 steps