Enjoy these free Code Nuggets?

Your support helps us create more high-quality content and unlocks exclusive premium nuggets via a personal activation link.

Support Our Work & Get Exclusive Access
🤖 New — AI Training

Learn to code with AI, not just about it.

Beyond free snippets, we run hands-on training in AI-assisted coding — teaching developers, teams and beginners how to build real software faster using modern AI tools. You bring the ideas; we show you how to ship them with an AI pair-programmer at your side.

  • ✔ Prompting & pairing with AI coding assistants to write, debug and refactor real code
  • ✔ Turning plain-English ideas into working apps, scripts and automations
  • ✔ Reviewing AI output safely — spotting bugs, security gaps and hallucinations
  • ✔ Live cohorts, team workshops and 1-on-1 mentoring — remote or on-site in Kenya
ai-pair-session.md

# You describe it…

"Build me a booking form that emails the client."

# …the AI drafts it…

▸ generating form + mailer…

â–¸ 24 lines written, 0 errors

# …and we teach you to lead it.

✱ You stay the engineer. AI is the tool.

Ruby on Rails nuggets

2 nuggets found

Clear filter

Keeping Controllers Skinny with Service Objects (Premium)

When a controller action does five things, it becomes hard to test and reuse. A service object captures one business operation in a single, callable class you can test in...

# app/services/register_patient.rb
class RegisterPatient
  def self.call(**args) = new(**args).call

  def initialize(name:, email:)
    @name = name
    @email = email
  end

  def call
    patient = Patient.create!(name: @name, email: @email)
    WelcomeMailer.with(patient: patient).greeting.deliv...

Readable Queries with ActiveRecord Scopes (Premium)

ActiveRecord scopes name your common queries so they read like intent, not SQL. They are chainable, composable, and keep filtering logic on the model where it belongs.

class Appointment < ApplicationRecord
  scope :upcoming,  -> { where("starts_at > ?", Time.current) }
  scope :for_doctor, ->(doctor) { where(doctor: doctor) }
  scope :confirmed, -> { where(status: :confirmed) }

  # Combine scopes into a higher-level one
  scope :doctor_agenda, ->(doctor) { upcomi...