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 8861927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:36:14+00:00 2026-06-14T15:36:14+00:00

When storing files in a custom directory (Eg: app/presenters/ ), how do you ensure

  • 0

When storing files in a custom directory (Eg: app/presenters/), how do you ensure that namespaced classes are loaded?

For example, if you have:

  • app/models/mega_menu.rb
  • app/presenters/catalog_presenter.rb
  • app/presenters/mega_menu/catalog_presenter.rb

Rails fails to load MegaMenu::CatalogPresenter:

CatalogPresenter.new
=> #<CatalogPresenter:0x85bca68 @_routes=nil>

MegaMenu::CatalogPresenter.new
(irb):3: warning: toplevel constant CatalogPresenter referenced by MegaMenu::CatalogPresenter
=> #<CatalogPresenter:0x85750a0 @_routes=nil>

I’ve created a sample Rails 3.2 app that reproduces this problem.

In config/application.rb, the app’s configured to load files in app/presenters/.

  • 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-06-14T15:36:15+00:00Added an answer on June 14, 2026 at 3:36 pm

    I solved this issue by using a require statement in an initializer. I don’t like it much but I liked the structure and class names of my application, they made sense so an initializer was my best solution. In the initializer try:

    require File.join(Rails.root, "app", "presenters", "mega_menu", "catalog_presenter")
    require File.join(Rails.root, "app", "presenters", "catalog_presenter")
    

    This problem occurs because autoload relies on const_missing being called which won’t happen in your case.

    When ruby first encounters a reference to MegaMenu::CatalogPresenter, the mega_menu/catalog_presenter.rb file has not been included. Standard ruby behaviour causes it walks up the namespace tree (figure of speech) and it instead finds the top level reference CatalogPresenter as this HAS been included at this point.

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

Sidebar

Related Questions

We have a sharepoint based application that uses a custom database for storing metadata/files
I currently have my assets in the jquery.rest.js and jquery-ui-1.8.11.custom.min.js files in my app/assets
In my app am creating some files and storing them in cache dir .
I'm planning on developing a Joomla custom component and storing the files in a
I have created a piece of code that checks files for a user-submitted string
Hi i have tried so much to open custom app from url, but i
I have an msi installer that needs to call a few batch files to
I have a question about loading properties from custom configuration files. I have tried
I have a directory full of email files, which look like this: From: Scoop
I have made a Custom Camera app and I am showing my image in

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.