Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:35:57+00:00 2026-05-22T21:35:57+00:00

I have a two part question. Question 1. I’ve always thought a folder was

  • 0

I have a two part question.

Question 1.

I’ve always thought a folder was an automatic namespace, but I just went back and refactored some code and ended up with something like this:

  • a folder named formatter
  • a file formatter.rb that contained references to all of the files within the folder
  • a formatter/formatter.rb file that has a class Formatter, with no reference to the namespace
  • 3 other classes that inherit from class Formatter: FooFormatter, BarFormatter, BazFormatter, with no reference to the namespace
  • one ActionFormatter class that does not inherit from class Formatter, and has no reference to the namespace

What surprised me was that I didn’t need to create namespaces around each of the file like I have in the past. Like:

Module Formatter
  Class ActionFormatter

Is this because the Module Formatter is implied by being in this folder? I still have to reference it as Formatter::ActionFormatter when it is called. But why doesn’t FooFormatter need this reference.

Question 2.

Everything seems to work, but I get this warning:

warning: toplevel constant FormatAction referenced by Formatter::FormatAction on the line where I have

@formatter = Formatter::ActionFormatter

Why is this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:35:57+00:00Added an answer on May 22, 2026 at 9:35 pm

    No, a folder does not define a namespace all by itself. The rails autoloading mechanism though, tries to load the definition for a non existint constant A::B::C within a/b/c.rb. If you define another constant there (especially without a namespace), it will exist (without namespace). If there is both, a toplevel constant and a namespaced constant with the same name and you access this constant from within the namespace, you get the above warning.

    When you go with rails, you have to define namespaced constants with their namespace, like this: class A::B::C < D. Also, as far as I know, inheritance does not influence namespacing in any way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two part question Best-Practice I have an algorithm that performs some
Ok so part two of I have no will power experiment is: Summary Question
I have a two part question. The first I think I have an okay
Two part question: Does the iPhone have a unique ID other than it's MAC
This is a two part question; firstly, does anyone out there have some insight
Two part question: Do browsers have a built-in CSS interpreter like they do for
This is a two part question, but I want to make sure the first
So let's say I have two different functions. One is a part of the
I have two rails apps on separate virtual servers, but in the same facility.
This is a two-part question: First, I am interested to know what the best

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.