include vs extend in Ruby: Clear Rules, Real Patterns
Understand exactly how include and extend work in Ruby, with method lookup rules, common mistakes, and production patterns.
Topic index generated on 2026-05-25 — grouped article list
Below is an index of articles grouped by topic. Click a heading to jump to the section.
If you find missing articles or inaccurate groupings, run ./scripts/update_index.py with appropriate flags.
Understand exactly how include and extend work in Ruby, with method lookup rules, common mistakes, and production patterns.
Complete guide to Ruby method arguments — positional parameters, default values, variable args with splat, keyword arguments, forwardable args, and common pitfalls.
A comprehensive guide to define_attribute_methods in Rails - generating attribute accessors, mutators, and query methods dynamically for ActiveRecord models.
Shopping Cart Goods Count Update in Rails(class variable)
Understand Rails mattr_accessor — how it creates module-level accessors, differs from cattr_accessor, and patterns for configuration modules.
Understand the difference between class variables (@@var) and class instance variables (@var) in Ruby — how they behave with inheritance and when to use each.
Understanding autoload in Rails - how Rails automatically loads constants and modules based on directory structure and naming conventions. Covers classic autoloader and Zeitwerk.
A complete guide to Ruby's context-switching methods — instance_eval, instance_exec, class_eval, and module_exec — with practical use cases and security considerations.
Learn how to use alias and alias_method in Ruby — renaming methods, wrapping behavior, and the key differences between the two.
A comprehensive guide to using alias and alias_method in Ruby for method aliasing, metaprogramming, code reuse, and Rails patterns.
Compare class variables (@@var), class instance variables (@var), and class_attribute in Ruby — inheritance behavior, use cases, and Rails patterns.
Content Class Methods
Thinking About ActiveRecord::Concern
A complete guide to Ruby constants — how constant lookup works, namespacing, the :: operator, and common pitfalls with nested classes.
A complete guide to Ruby's Hash and Struct — their differences, use cases, and when Struct is the better choice for structured data.
Understanding Aspect-Oriented Programming (AOP) in Ruby - patterns, implementation, and use cases for separating cross-cutting concerns.
Learn how Ruby's prepend works, how it differs from include, and when to use each for module composition and method wrapping.
A curated collection of essential Ruby articles covering modules, metaprogramming, equality operators, and the Ruby object model.
A complete guide to Ruby's singleton methods and singleton class — what they are, how they work, and how they underpin class methods and Ruby's object model.
A complete guide to Ruby's dynamic dispatch — using send, public_send, and method objects to call methods dynamically, bypass visibility, and build flexible APIs.
A complete guide to Ruby's attribute accessors — attr_accessor, attr_reader, and attr_writer — with examples, custom implementations, and best practices.
Practical patterns for using Ruby class variables as counters — with thread safety, inheritance considerations, and better alternatives.
A complete guide to Ruby's method_missing — how it works, practical use cases, and how to implement it safely with respond_to_missing?.
A deep dive into Ruby class instance variables — how they differ from class variables, how inheritance works, and how Rails class_attribute builds on them.
A complete guide to Ruby class variables (@@var) — how they work, how they behave with inheritance, thread safety concerns, and why class instance variables are usually preferred.
Learn the Ruby class extension pattern — using self.included and extend(ClassMethods) to add both instance and class methods when a module is included.
A complete guide to Ruby class methods — the three ways to define them, singleton methods, inheritance, and practical patterns.
Learn how to implement and use a blank? helper in Ruby — handling nil, empty strings, whitespace, and falsy values cleanly.
Understand Ruby's class_eval, module_eval, and instance_eval — how they switch evaluation context, when to use each, and practical metaprogramming examples.
Understand the difference between interface inheritance and implementation inheritance, with practical examples in Ruby and Go.
Implement the attr_checked pattern from the Metaprogramming Ruby book — dynamic attribute validation using define_method, modules, and callbacks.
Understand the risks of Ruby's dynamic nature — methods that fail only at runtime, how to mitigate them with tests and static analysis, and what this means for production code.
A real-world debugging story: fixing a Capistrano deploy failure caused by a gem major version bump, with lessons on dependency management and semantic versioning.
An honest assessment of Ruby as a programming language — its strengths in expressiveness and developer happiness, its performance trade-offs, and where it fits in 2026.
Use Rails callbacks to maintain data consistency across associated models — automatic OrderItem creation, cascade deletion, and avoiding callback hell.
Understand the difference between ActiveRecord::Relation and model objects in Rails — lazy loading, query chaining, and when to use find vs where.
How to avoid duplicate HTML element IDs in Rails when rendering multiple forms on the same page — using the namespace option and modern form helpers.
A complete guide to Ruby's equality and comparison operators — ==, eql?, equal?, <=>, and === — what each means and when to use each.
A deep dive into Ruby's object model — how objects, classes, modules, and the method lookup chain work, with comparisons to Python and Go.
How to Create a Gem For JavaScript and CSS Libraries
A complete guide to loops and iteration in Ruby — times, upto, each, while, until, loop, map, select, and when to use each.
A complete guide to Ruby's method visibility: public, private, and protected — what they mean, how they work, and when to use each.
A complete guide to understanding self in Ruby — what it refers to in different contexts, how it works in classes, modules, and singleton methods.
A complete guide to Ruby instance methods — the three ways to define them, singleton methods, unbound methods, and dynamic method definition.
A complete guide to Ruby's include and extend — how they differ, when to use each, and the classic pattern for adding both instance and class methods via a module.
A complete guide to sessions in Rails — how they work, storage options, security considerations, and best practices for authentication.