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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:00:10+00:00 2026-06-04T06:00:10+00:00

Update: This problem no longer exists in Rails 3.2 I am trying to get

  • 0

Update: This problem no longer exists in Rails 3.2

I am trying to get an array containing all the models in my rails 3 application. I am trying:

ActiveRecord::Base.send(:descendants)

for the same. A similar discussion happened in the question: Is there a way to get a collection of all the Models in your Rails app?. As pointed out in one of the answers, we need to touch the models for the models to show up. That is precisely the problem I am facing.

There are more than a dozen models in my rails app, but

ActiveRecord::Base.send(:descendants) 

returns an array of size two. The array has just User and ActiveRecord::SessionStore::Session models. I don’t get the other models untill I touch the model by touching, say invoking Comment.new
How can I get all the models listed without touching all the models?

Another additional piece of information that might be useful is that I am using devise for authentication. Maybe devise is doing things in a desired way as far as User model is concerned and I am not doing those things with the other models.

Thanks a lot in advance.

  • 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-04T06:00:12+00:00Added an answer on June 4, 2026 at 6:00 am

    You need to load the models first:

    Dir[Rails.root + "app/models/**/*.rb"].each do |path|
        require path
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when trying to execute this update statement (below) using C#
UPDATE It looks like this problem has been quietly fixed in iOS 4.3. Up
Update: After some more reading I see that this problem is totally general, you
Update: This is, as I was told, no principle Python related problem, but seems
Update II Problem Solved but Why? This has been the biggest headache ever. My
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:
I have a problem with the logic of this code, XNA's Update Method is
I have this code, but I have a problem. When I update but do
i have problem use link_to_remote link_to_remote document example say link_to_remote Delete this post, :update
UPDATE: This question and its answers should no longer be recommended to anyone reading

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.