rubyguides

Guides

Guides

In-depth guides for Ruby developers.

  1. Ruby WebSockets: Building Real-Time Features with ActionCable

    Ruby WebSockets made practical: learn websocket-ruby, ActionCable, and async-websocket for real-time chat, notifications, and live dashboards across any stack.

  2. The Builder Pattern in Ruby: Step-by-Step Object Assembly

    Learn to implement the builder pattern in Ruby for cleaner step-by-step object construction with fluent interfaces, nested structures, and inline validation.

  3. The Command Pattern in Ruby: Encapsulating Actions as Reusable Objects

    Implement the command pattern in Ruby — encapsulate requests as objects, enable undo/redo, queue operations, and build extensible CLI apps.

  4. Ruby array methods: map, select, reduce, and more

    Learn the 7 Ruby array methods you will use every day: map, select, reduce, find, sort_by, uniq, and flatten. Practical patterns and real examples included.

  5. ActiveSupport Outside of Rails

    Use ActiveSupport outside of Rails: cherry-pick core extensions, time utilities, and number helpers for plain Ruby scripts and gems without the full framework

  6. Configuration Patterns in Ruby

    Learn configuration patterns in Ruby for designing and managing config using module-level config, Config objects, ENV variables, and YAML files

  7. Date Time in Ruby: Instants, Calendar Days, and Timestamps

    Learn date time handling in Ruby: Time, Date, and DateTime classes, parsing, formatting with strftime, timezone conversion, and arithmetic.

  8. The Decorator Pattern in Ruby: Extending Objects at Runtime

    Master the decorator pattern in Ruby: extend objects at runtime with SimpleDelegator and Forwardable for clean, composable object design.

  9. Dependency injection in Ruby: constructor, setter, and method patterns

    Learn dependency injection in Ruby through constructor, setter, and method injection patterns that improve testability and make your code easier to change.

  10. Practical hash tricks in Ruby for day-to-day data work

    Practical hash tricks in Ruby for transforming keys, digging into nested data, fetching safely, handling defaults, and choosing the right object model.

  11. HTTP clients in Ruby: Net::HTTP, Faraday, and HTTParty

    Choose the right HTTP clients in Ruby with this practical guide to Net::HTTP, Faraday, and HTTParty. Compare approaches, handle errors, and pick the best tool.

  12. JSON XML in Ruby: How to Parse, Generate, and Transform Data

    Learn json xml handling in Ruby: parse, generate, and manipulate JSON and XML data with practical examples and performance guidance.

  13. Ruby Logging Guide: How to Use the Built-in Logger Class

    A practical guide to Ruby logging with the standard library Logger class. Covers log levels, formatting, rotation, and production best practices for Ruby apps.

  14. The Null Object Pattern in Ruby

    The Null Object pattern eliminates nil checks by providing objects that respond to the same interface as real ones, with practical Ruby and Rails examples.

  15. Observer pattern in Ruby: Observable, custom observers, and events

    Learn how to implement the observer pattern in Ruby using the built-in Observable module, custom implementations, and ActiveSupport::Notifications.

  16. Service Objects in Ruby: Extract Business Logic from Controllers

    Learn how service objects help you extract complex business logic from your Rails controllers and models into focused, testable Ruby objects.

  17. Strategy Pattern in Ruby: A Design Pattern for Runtime Swaps

    Implement the strategy pattern in Ruby to isolate algorithms, swap behaviors at runtime, and replace complex conditionals with interchangeable objects.

  18. State machines in Ruby with AASM: a practical guide

    Model object lifecycles with state machines in Ruby using the AASM gem. Covers states, events, transitions, guards, callbacks, and ActiveRecord integration.

  19. String manipulation in Ruby: create, index, and format text

    A practical guide to string manipulation in Ruby covering creation, indexing, slicing, substitution, case conversion, splitting, joining, and encoding.

  20. Ruby value objects: immutable data with value equality

    Learn how to model Ruby value objects with immutable state, equality by value, and practical implementations using Struct, Data, and plain objects.

  21. Comparable and Enumerable in Ruby

    Ruby's Comparable and Enumerable modules give objects sorting and iteration for free. Learn the spaceship operator and each method with practical examples.

  22. Working with IO and files in Ruby

    Read, write, and manage IO and files in Ruby using File, IO, StringIO, and Dir with practical examples, edge cases, and common pitfalls.

  23. Ruby Symbols Deep Dive: How They Work Under the Hood

    A symbols deep dive into how Ruby symbols work under the hood, their performance advantages as hash keys, and when to choose them over strings.

  24. Benchmarking Ruby code: measure and compare performance

    Learn benchmarking Ruby code with the Benchmark module and benchmark-ips gem. Measure execution time, compare approaches, and avoid common measurement pitfalls.

  25. ERB Templates Outside of Rails

    Learn how to use ERB templates without Rails to render mailers, static site generators, code generation, and other text files safely.

  26. Building Ruby CLIs with OptionParser

    Learn building Ruby CLIs with OptionParser: flags, type coercion, custom converters, help generation, and practical patterns for production tools.

  27. DRb distributed Ruby: building networked Ruby objects

    Learn DRb distributed Ruby basics, including process communication, exposed objects, and the choice between copies and remote references.

  28. YAML.safe_load: Safely Deserialize YAML in Ruby

    Use YAML.safe_load to safely parse YAML in Ruby. Prevent remote code execution, whitelist permitted classes, and handle Ruby 3.1 breaking changes.

  29. Lazy Enumerators for Large Datasets

    Master lazy enumerators in Ruby with Enumerator::Lazy. Process large datasets without loading everything into memory, with practical examples.

  30. How method_missing and respond_to_missing? Work in Ruby

    Understand method_missing and respond_to_missing? in Ruby with practical examples of dynamic dispatch, DSLs, delegation, and safer metaprogramming patterns.

  31. Socket Programming in Ruby: TCP, UDP, and Network Clients

    Learn socket programming in Ruby by building TCP and UDP clients and servers using TCPServer, TCPSocket, UDPSocket, and the Socket class with examples.

  32. Tempfile and Tmpdir for Temporary Storage

    Ruby's Tempfile and tmpdir utilities handle temporary storage with automatic cleanup. Learn block-based APIs and security defaults for scratch files in Ruby.

  33. Rails Caching: Speed Up Your App with Fragment and Russian Doll

    Learn rails caching with low-level caching, fragment caching, Russian doll caching, and cache expiration for faster Rails apps.

  34. Ruby Pattern Matching: Arrays, Hashes, and Data Extraction

    Learn Ruby pattern matching in Ruby 3: array and hash destructuring, guard conditions, data validation, and API response parsing with case...in syntax.

  35. Ruby Fiber Scheduler for Async IO in Practice

    Learn how the Ruby fiber scheduler enables async IO operations, implement non-blocking code, and handle thousands of concurrent connections efficiently.

  36. Using Ruby Struct for lightweight data objects

    Learn how Ruby Struct creates lightweight data objects with named fields, predictable accessors, and less boilerplate than a full class.

  37. Ruby 3.2 Data Class: Immutable Value Objects with Pattern Matching

    Define immutable value objects with Ruby's Data class — frozen by default, keyword-only arguments, and first-class pattern matching support.

  38. Debugging Ruby with the debug Gem

    Learn debugging Ruby with the official debug gem, step through code, inspect variables, and fix bugs from the CLI or source.

  39. Digest hashing in Ruby: MD5, SHA256, and more

    Learn digest hashing in Ruby with the Digest module, including SHA256, MD5, SHA1, file hashing, incremental updates, and the security tradeoffs you should know.

  40. Frozen String Literals and Immutability in Ruby

    Learn how Ruby handles frozen string literals, their performance benefits, and how to work with mutable strings when needed.

  41. Ruby GC Tuning and Memory Profiling

    Learn how to tune Ruby's garbage collector and profile memory usage in your applications. Covers GC.stat, environment variables, and profiling tools.

  42. Refinements — Scoped Monkey Patching

    Learn about refinements, scoped monkey patching in Ruby that lets you modify core classes safely within a single file or module without global side effects.

  43. Ractor-Based Concurrency

    Learn how Ractors communicate via message passing, build pipelines and worker pools, and avoid the shared-state pitfalls of threads.

  44. Working Arrays in Ruby: A Practical Guide

    A practical guide to working arrays in Ruby. Covers creation, filtering with select, transforming with map, sorting, and avoiding common pitfalls.

  45. Working with hashes in Ruby: lookups, merges, and filtering

    Learn how working with hashes in Ruby simplifies everyday data tasks. Practical examples for lookup, merging, filtering, conversion, and common patterns.

  46. Working strings: trimming, searching, and formatting in Ruby

    A practical guide to working strings in Ruby. Covers trimming, case conversion, searching, replacing, splitting, and interpolation with real code.

  47. Understanding Blocks, Procs, and Lambdas in Ruby

    A complete guide to understanding blocks, procs, and lambdas in Ruby ; the closure primitives that make Ruby powerful.

  48. Sidekiq Background Jobs: How to Run Async Work in Ruby

    Learn how Sidekiq background jobs work in Ruby, from installing the gem and creating workers to managing queues, configuring retries, and testing.

  49. Ruby Concurrency with Threads: Mutex, Thread Pools, and Patterns

    Ruby concurrency with threads made practical: learn Thread.new, join, Mutex, thread-local variables, and patterns to avoid race conditions and deadlocks.

  50. Managing Gems with Bundler: Gemfile, Install, and Update

    Learn managing gems with Bundler: Gemfile syntax, version constraints, bundle install, Gemfile.lock, and common commands for reproducible Ruby projects.

  51. Metaprogramming basics in Ruby

    A comprehensive guide to Ruby metaprogramming basics, covering dynamic methods, define_method, method_missing, and runtime code execution.

  52. Making HTTP Requests in Ruby with Net::HTTP

    A guide to making HTTP requests with Net::HTTP in Ruby. Covers GET, POST, headers, response handling, errors, and scripting patterns.

  53. Open classes and monkey patching in Ruby

    Learn how Ruby's open classes work, the risks of monkey patching, and best practices for safely modifying existing classes and extensions.

  54. Regular Expressions in Ruby: Guide to Pattern Matching

    Master regular expressions in Ruby with this complete guide to pattern matching, regex features, string manipulation, and practical code examples.