Rails Scopes: How To Write Better Queries
Learn how Rails scopes make Active Record queries cleaner, reusable, and easier to maintain with practical examples.
Jean Emmanuel is a Full-Stack Software Engineer specializing in Ruby on Rails and the modern Rails ecosystem. He builds scalable, maintainable web applications using Rails, Hotwire (Turbo & Stimulus), PostgreSQL, and SQLite, with a focus on fast, dynamic user experiences. Through CodeCurious, he shares practical lessons, development insights, and real-world solutions for modern developers.
Learn how Rails scopes make Active Record queries cleaner, reusable, and easier to maintain with practical examples.
Learn how Rails cache keys work, including cache_key, cache_key_with_version, fragment caching, and cache invalidation.
Learn the difference between pluck and select in Rails, what SQL each generates, and when to use them in Active Record queries.
Learn when to use find_each vs. each in Rails, how batching works, and how to process large datasets without memory issues.
Learn the difference between Rails joins and left_joins, how each generates SQL, and how to avoid common query mistakes.
Learn how Rails Credentials work: encrypt secrets, secure your master key, and manage config safely in development and production.
Learn how Rails transactions work: ActiveRecord commits, rollbacks, savepoints, and after_commit callbacks explained.
Learn how Ruby blocks, Procs, and lambdas work, how they differ, and when to use each in real-world Ruby applications.
Learn how database indexes work in Rails, when to add them, how to use migrations, and how indexes improve query performance.
Compare Active Job and Sidekiq in Rails: features, performance, reliability, setup, and when to use each for background jobs.