How to track and log slow queries in Ruby on Rails applications?

How to track and log slow queries in Ruby on Rails applications?

Slow SQL queries in Rails can be caught in development, before they become production fires. Using ActiveSupport::Notifications and the sql.active_record event, you build a small performance guard that logs every query above a time threshold straight to your console.

Deprecation in Rails: How to gracefully remove old code

Deprecation in Rails: How to gracefully remove old code

Deprecation lets you remove old Rails code without breaking teammates' apps overnight. A practical look at ActiveSupport::Deprecation: why sudden deletes hurt, how to warn about methods scheduled for removal, and how to phase out code in a civilized way.

How to create a custom rubocop rule to improve code quality?

How to create a custom rubocop rule to improve code quality?

Custom RuboCop cops let you enforce your project's own conventions. Step by step: how cops inspect the abstract syntax tree, writing a cop that bans hardcoded phone numbers, wiring it into your RuboCop config, and watching it flag offenses in action.

How to extend rake tasks with pre and post hooks in Ruby on Rails

How to extend rake tasks with pre and post hooks in Ruby on Rails

Rake's enhance method adds pre and post hooks to any task without touching its code: back up the database before migrations run, or send a notification after a deploy task completes. Examples of prerequisites, post-execution blocks, and combining both hooks.

Transforming YAML config files into Ruby objects with helpers

Transforming YAML config files into Ruby objects with helpers

YAML config files don't have to end up as messy nested hashes. Turn them into real Ruby objects with validation and custom methods: a small model class that loads the YAML, exposes clean accessors, and grows with your Rails app's configuration needs.

Creating predictable randomness in Ruby: The magic of seeds

Creating predictable randomness in Ruby: The magic of seeds

Reproducible randomness in Ruby sounds like a contradiction, but seeds make it easy: how pseudo-random generators work, fixed seeds for tests, debugging, and procedural generation, creative ways to pick seeds, and the pitfalls that quietly break determinism.

Leveraging JSON in PostgreSQL 17

Leveraging JSON in PostgreSQL 17

PostgreSQL 17 finally implements the SQL/JSON standard: constructors like JSON_OBJECT and JSON_ARRAYAGG, query functions JSON_EXISTS and JSON_QUERY, and the star of the release, JSON_TABLE, which turns JSON into rows, shown on a real IoT data example.

PostgreSQL indexing for newbies - Practical Guide

PostgreSQL indexing for newbies - Practical Guide

PostgreSQL indexing explained for beginners: how B-tree, BRIN, GIST, and GIN indexes work, reading EXPLAIN ANALYZE to see if they are used, maintenance and hit rate tips, and clear rules for when an index helps and when it just slows your writes down.