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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:01:45+00:00 2026-05-20T05:01:45+00:00

I am using Rails 2.3.5, and in it, to autoload classes from lib folder,

  • 0

I am using Rails 2.3.5, and in it, to autoload classes from lib folder, we just have to name the files according to their classnames

lib/auto_run.rb --> class AutoRun
lib/code_snippets/category_code --> class CodeSnippets::CategoryCode

It is similar to the Rails model naming except for the s. Here, I am confused about the latter one. Here, I havent defined a module or another class CodeSnippets anywhere. Then how can I use :: operator?

Also is there any other ways of folder structure so that Rails could autoload classes without writing extra code?

  • 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-20T05:01:46+00:00Added an answer on May 20, 2026 at 5:01 am

    In CodeSnippets::CategoryCode you don’t need to declare CodeSnippets because it is not more than a namespace, it is not a Module or a Class

    This classes just get autoloaded because by convention, all the files in lib/ get autoloaded, in the same way the /models and the controller/ folders get also autoloaded.

    If you want to get more folders autoloaded you have to add them to the load_paths config variable in environment.rb like this:

      config.load_paths += %W(#{RAILS_ROOT}/app/middleware)
      config.load_paths += %W(#{RAILS_ROOT}/app/observers)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails 3.0.7. I have a simple form which shows all records from one
Using rails and rspec it's easy to have rspec generate the necessary files for
Using Rails 3.1.0, with Active Scaffold (from the git repo). My controllers have code
Using Rails v2.1, lets say you have an action for a controller that is
I am using rails beta 3 and I have a erb page named index.html.erb
I'm using rails 3.0 and MySql 5.1 I have these three models: Question, Tag
We are using Rails 2.3.5 and have been experiencing seemingly random Timeout::Error: execution expired
I'm using rails 3. In my index.html.erb and in my index.js.erb, if I have:
I'm using Rails to send emails and I just want to send a plain
I'm using Rails 2. I have resources nested like this: - university_categories - universities

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.