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.
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.
A comprehensive guide to using alias and alias_method in Ruby for method aliasing, metaprogramming, code reuse, and Rails patterns.
Content Class Methods
Learn how Ruby's prepend works, how it differs from include, and when to use each for module composition and method wrapping.
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 complete guide to Ruby class methods — the three ways to define them, singleton methods, inheritance, and practical patterns.
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.
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 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.