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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:00:16+00:00 2026-05-26T10:00:16+00:00

I like how Rails has each controller in it’s own file and it’s automatically

  • 0

I like how Rails has each controller in it’s own file and it’s automatically loaded and I’m trying to do the same for my Sinatra site.

I have, for example, my “Users” pages, which is users/login, users/logout and so on, what I’d like to do is seperate all these, and other pages, like news, admincp, and so on into their own files.

How would I go about having them auto loaded when my Sinatra site is started?

  • 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-26T10:00:16+00:00Added an answer on May 26, 2026 at 10:00 am

    This is how I accomplished this with my project.

    I put all the “controllers” in a directory, I then created a file named init.rb with the following code:

    Dir.glob(File.dirname(__FILE__) + '/*.rb').each do |controller|
     require(controller)
    end
    

    Then in my main app file the following code:

    __DIR__ = ::File.dirname(__FILE__)
    require __DIR__ + '/controllers/init'
    

    Hope this helps.

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

Sidebar

Related Questions

I am currently implementing a blog-like site using Ruby on Rails. Each Post has
In my Rails 3 app, I have a list of questions. Each question has
I have a Rails 3 site I'm working on that has users who operate
I have a text like this: 'Rails on IIS7 http://is.gd/vWPn ' (it's a tweet
Is there an equivalent to Rails-like polymorphic associations in Doctrine? I'm trying to do
I'm trying to make logging for my rails app and have some dilemmas over
I have built a blog application w/ ruby on rails and I am trying
I have a blog with posts in multiple categories. I'd like to give each
I'm creating a Ruby on Rails app that consists of stories. Each story has
I have an old site built in Coldfusion, a new site built in Rails.

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.