<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94" -->

---
title: Why you should nest modules in Ruby | daily.dev
description: Learn about the functional differences between nested and inline modules in Ruby, including how referencing classes differs and why this behavior occurs....
canonical: https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why you should nest modules in Ruby | daily.dev
og:description: Learn about the functional differences between nested and inline modules in Ruby, including how referencing classes differs and why this behavior occurs....
og:url: https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94
og:image: https://api.daily.dev/og/posts/JPZOVOh94.png
og:image:alt: Why you should nest modules in Ruby
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why you should nest modules in Ruby

**[thoughbot](https://daily.dev/sources/thoughbot)** · 3 min read · 1 upvotes · 0 comments

## Summary

Learn about the functional differences between nested and inline modules in Ruby, including how referencing classes differs and why this behavior occurs. Discover the benefits of nesting modules and the potential issues with using inline modules.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://thoughtbot.com/blog/why-you-should-nest-modules-in-ruby>

---

Tags: [#ruby](https://daily.dev/tags/ruby)

[View this post on daily.dev](https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why you should nest modules in Ruby","url":"https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94"},"datePublished":"2024-05-16T00:04:50.004Z","dateModified":"2024-05-16T00:04:48.142Z","description":"Learn about the functional differences between nested and inline modules in Ruby, including how referencing classes differs and why this behavior occurs....","image":"https://media.daily.dev/image/upload/s--HRgLpUt6--/f_auto/v1722860399/public/Placeholder%2003","thumbnailUrl":"https://media.daily.dev/image/upload/s--HRgLpUt6--/f_auto/v1722860399/public/Placeholder%2003","isAccessibleForFree":true,"articleSection":"thoughbot","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"thoughbot","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/9fe12feb57f944a29ff63a79e350081a","url":"https://daily.dev/sources/thoughbot"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/why-you-should-nest-modules-in-ruby-jpzovoh94","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ruby","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"thoughbot","item":"https://daily.dev/sources/thoughbot"},{"@type":"ListItem","position":3,"name":"Why you should nest modules in Ruby"}]}
```

