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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:33:55+00:00 2026-05-19T00:33:55+00:00

I have a over 100 models in my rails application, and just for organization,

  • 0

I have a over 100 models in my rails application, and just for organization, I’m dividing them into folders, all still under the main model folder, just to make it simpler to navigate on the project and see files that are related.

Is this a bad idea? What is the rails way to do 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-19T00:33:56+00:00Added an answer on May 19, 2026 at 12:33 am

    No, it’s not a bad idea. Many people do it and I couldn’t live without it in large applications.

    There are two ways of doing it:

    The first is to just move your models. You will, however, have to tell Rails to load the wayward models (as it won’t know where they are). Something like this should do the trick:

    # In config/application.rb
    module YourApp
      class Application < Rails::Application
        # Other config options
    
        config.autoload_paths << Dir["#{Rails.root}/app/models/*"]
      end
    end
    

    The first way is easy, but is not really the best way. The second way involves namespacing your models with groups they’re in. This means that instead of having User and UserGroup and UserPermissions, you have User, User::Group and User::Permission.

    To use this, generate a model like this: rails generate model User::Group. Rails will automatically create all of the folders for you. An added benefit is that with this approach, you won’t have to spell out the full model name for associations within a namespace:

    class User < ActiveRecord::Base
      belongs_to :group # Rails will detect User::Group as it's in the same namespace
    end
    
    class User::Group < ActiveRecord::Base
      has_many :users
    end
    

    You can specify however many levels of namespacing as you want, so User::Group::Permission would be possible.

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

Sidebar

Related Questions

If I'm building an application that will have over 30 models, and I want
I'm sure it's something simple, but I have over 100 errors like: and: I
I have a directory containing over 100 html files. I need to extract only
I have a list view with over 100 items. Each of these items show
We have a very complex Oracle package here (over 4,100 lines of code) that's
I have the following query: select top 100 eid, cid, id, position, ROW_NUMBER() over(order
Say I have real, dimension(0:100) :: realResults and I want to iterate over realResults
We have over 1000 unit tests. A while ago 18 of them started to
We all know the effects that lots of thrown exceptions can have over the
I'll just jump right into it. I have a model called Request which I

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.