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

  • Home
  • SEARCH
  • 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 6045241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:06:10+00:00 2026-05-23T07:06:10+00:00

On a Rails application I’m working on, I have a model Type that relates

  • 0

On a Rails application I’m working on, I have a model “Type” that relates to the single-table-inheritance model “Node”: any possible subclass of Node is defined as a Type in the types table.

Right now this is made possible loading all classes in an initializer, but I’d like to load the subclasses only when they are required.

The best solution I can think of would be having a fallback on an uninitialized constant that would check if that constant can represent a class in the application, something similar to what method_missing does.

I’d like some advice on how and where to define this logic, or if there’s a better solution altogether.

  • 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-23T07:06:10+00:00Added an answer on May 23, 2026 at 7:06 am

    There’s Module#const_missing:

    http://apidock.com/ruby/Module/const_missing

    I assume you can (ab)use that for your needs.

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

Sidebar

Related Questions

In my rails application, I have a background process runner, model name Worker, that
I have a rails application that helps users submit articles. Does any one know
I have a Rails application that in the erb code, I use a select
My Rails application have a User model and a Group model, where User belongs
I have a Rails application that has to co-exist with a very old legacy
A Rails 3 application I'm working on contains some logic that invokes the following
In a rails application, I have a number of attributes for a model called
We have a rails application in subversion that we deploy with Capistrano but have
I have rails application that connects to multiple databases. I wrote custom rake task
I have a Rails application that has a Company resource with a nested resource

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.