devcontainer
devcontainer
ruby
Integrating .ruby-version into your Rails Gemfile
Stop declaring your Ruby version twice: with a recent Bundler your Gemfile can read .ruby-version directly using ruby file: ".ruby-version". The one-line setup, the required Bundler upgrade, and how it keeps rbenv, RVM, or asdf and Rails in sync.
ruby
What is Turbo Frames in Rails?
Turbo Frames let Rails reload just a fragment of the page instead of the whole thing, with no custom JavaScript. What Turbo Frames are within Hotwire, a practical example of wrapping views in frames, and the responsiveness gains you get almost for free.
Latest
Introducing Threads, Parallelism, and Mutex in plain Ruby
Ruby threads explained in plain Ruby: how threads speed up I/O-heavy work, how race conditions corrupt shared resources, and how a Mutex protects critical sections, with runnable examples and no framework required.
How to create a simple parallelized web scraper using Ruby and Async
Build a parallel web scraper in Ruby with the async and async-http gems: fetch many URLs concurrently using Async tasks, a Barrier to wait for results, and a Semaphore capping requests at eight at a time, all in one short script.
Struct vs Data in Ruby 3.2
Struct vs Data in Ruby 3.2: what the new immutable Data class does differently, when mutability still makes Struct the right choice, how to extend Data, and benchmarks comparing Data, Struct, and OpenStruct performance.
Improve the performance of your Rails application through load testing
Load testing a Rails application step by step: why simulating peak traffic matters, how to set up a test machine and build complex scenarios, which performance metrics to measure, and how to turn the results into optimizations.
Implementing read and write databases in Rails
Rails read and write databases in practice: configure a primary and replica in database.yml, enable automatic connection switching, update ApplicationRecord, and handle the replication challenges that come with splitting the load.
How to send files from Javascript/React to a Ruby on Rails API Controller
Sending files from JavaScript or React to a Rails API: build a FormData object with the file and extra params, POST it with fetch, then read params[:file] in your controller. A minimal frontend plus backend walkthrough that works.
How to create rake task and pass arguments
Creating rake tasks and passing arguments, four ways: the default bracket syntax, OptParse, raw ARGV, and Linux-style flags, plus namespaces and prerequisites for organizing tasks in a Rails app, each with a working example.
Adding Custom Inflections in Rails with Zeitwerk
Custom inflections in Rails with Zeitwerk: use ActiveSupport::Inflector in config/initializers/inflections.rb to register acronyms like API, CSV, or SSL, so autoloading maps file names to the capitalized class names you want.
Block attackers based on request URL in Ruby app
Blocking bots and attackers by request URL instead of IP: how the url_ban_list gem, born from three years of honeypot observations, recognizes malicious scan paths in your Ruby app and bans the clients requesting them.
Add commit message validator using Ruby and Lefthook
Enforce consistent commit messages with a small Ruby script and Lefthook: a commit-msg hook that reads .git/COMMIT_EDITMSG, validates prefixes like feat, fix, or docs against a regex, and rejects bad messages before they land. Full script and Lefthook config included.
How to work with JSONB column in pure Ruby on Rails
JSONB columns in Ruby on Rails without extra gems: use store_accessor to read and write keys like normal attributes, set sensible defaults, and validate required keys with a small module. Practical code you can drop into a PostgreSQL-backed Rails app.
Demystifying and writing own DSL in Ruby by examples - a practical guide
Ruby DSLs demystified by building three of them: a Minitest-like test framework, a Rails-style routes definition, and an RSpec-like spec syntax. See how blocks, instance_eval, and Ruby metaprogramming turn plain classes into a friendly mini-language.
Painting 'Lady with a weasel' using genetic algorithms and Ractor parallelism in Ruby
Genetic algorithms meet Ruby Ractors: a script that repaints Lady with a Weasel generation by generation. Follow the full lifecycle (mutation, fitness scoring, crossover), see how Ractor parallelism speeds up scoring specimens, and view the final result.
How to solve Selenium::WebDriver::Error::ScriptTimeoutError: script timeout
Selenium::WebDriver::Error::ScriptTimeoutError in Capybara system tests often appears after a Chrome driver update, and the culprit is default_max_wait_time set to zero for non-headless debugging. Why the error happens and the one-line config change that fixes it.
What is ETag and how to use it in Rails for caching?
ETags let browsers skip downloading content that has not changed. What entity tags are in HTTP, then the Rails caching toolkit: stale?, fresh_when, expires_in, expires_now, public requests, and http_cache_forever, each shown with a concrete controller example.
Understanding the Singleton Pattern in Ruby
The Singleton pattern in Ruby, shown two ways: a hand-rolled class using private_class_method :new with a self.instance accessor, then a cleaner refactor with the built-in Singleton module. What the pattern guarantees and when one shared instance is worth it.
What is ACID?
ACID stands for Atomicity, Consistency, Isolation, and Durability: the four guarantees behind reliable database transactions. Each property explained with a concrete Rails example, like wrapping a money transfer in a transaction so it fully succeeds or rolls back.
What is instance and class variable in Ruby?
Instance variables versus class variables in Ruby: what @ and @@ actually mean, why an @ variable set at the class level stays empty when read from an instance, and how @@ values are shared by every instance. Short code samples make each behavior easy to verify.
What is cattr_accesor and mattr_accessor, thread_cattr or thread_mattr in Ruby and in Rails?
cattr_accessor, mattr_accessor, and the thread_cattr and thread_mattr variants explained: ActiveSupport helpers for class-level and module-level attributes, plus thread-safe versions that avoid data inconsistencies in multi-threaded apps. Examples for each accessor, reader, and writer.
Extend, prepend and include in Ruby
Extend, prepend, and include in Ruby each add module code to a class differently: prepend puts the module before the class so its methods win, extend adds class methods, include adds instance methods. Short runnable examples show how each changes the method lookup chain.