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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:24:48+00:00 2026-05-11T11:24:48+00:00

I’m trying to learn the life cycle of a rails application. When is application_controller.rb

  • 0

I’m trying to learn the life cycle of a rails application. When is application_controller.rb run? Is it just once every time it’s changed, or on every request?

I want to know the same about the following file:

  • config/environments/*.rb (development, production, or test, depending on the current mode)
  • boot.rb
  • environment.rb
  • routes.rb

One of the reasons I’m asking this is, I want to know where is a good place to put

  • initialization code
  • custom configuration data

EDIT:

@Gdeglin’s answer is good, but I’m actually interested in knowing when each of these files run.

  • 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. 2026-05-11T11:24:48+00:00Added an answer on May 11, 2026 at 11:24 am

    application_controller.rb

    ApplicationController is a parent class to all controllers. Methods declared in it will be available to all controllers for this reason.

    ApplicationController is a convenient place to filters that you want to apply to all controllers in your application, or methods that you wish to make available to all of them.

    config/environments/*.rb

    The files in config/environments/*.rb override settings in the default config/enviornment.rb file depending on what environment your server is running in (development/production). One example is that in development errors are printed to the screen and in production a generic error page is returned. This setting is in config/environments/development.rb

    boot.rb

    boot.rb is used as part of the rails initialization process. You usually don’t need to, and likely shouldn’t touch it.

    environment.rb

    environment.rb is the generic configuration file for your application.

    routes.rb

    routes.rb is used to define how your application handles requests to specific urls. For example, you may want to have all 404 requests go to a specific action instead of being handled by the default error handler:

    map.connect '*path', :controller => 'home', :action => 'on_404' 

    It is also an important part of implementing a RESTful application.

    Where to place initialization & configuration code

    Both initialization code and custom configuration data should be placed in enviornment.rb (read the comments in this file). If you want certain code to run during initialization only in development or only in production, place it in config/environments/development.rb or config/environments/production.rb respectively.

    Edit:

    A good overview on when each of these files is run during initialization is available here:

    http://toolmantim.com/articles/environments_and_the_rails_initialisation_process https://github.com/toolmantim/toolmantim/blob/master/articles/environments_and_the_rails_initialisation_process.haml

    Essentially the steps are:

    1. The Rails Initializer is loaded (http://api.rubyonrails.org/classes/Rails/Initializer.html)

    2. The rails Initializer sets up logging and then loads environment.rb

    3. environment.rb loads boot.rb

    4. boot.rb sets the RAILS_ROOT constant and adds rails libraries and application code to the LOAD_PATH

    5. environment.rb executes Rails::Initializer.run.

    6. The rails framework is loaded (ActiveRecord, ActionMailer, etc.)

    7. Your environment’s specific config file is loaded (config/environments/development.rb.)

    8. after_initialize and to_prepare callbacks are executed if you have created any

    9. Rails has finished loading and is ready to handle requests

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

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer If you're using rails' static page caching and serving through… May 11, 2026 at 3:20 pm
  • added an answer You need to set the option connectToSortable in the draggable… May 11, 2026 at 3:20 pm
  • added an answer hasattr() is the best choice. Go with that. :) if… May 11, 2026 at 3:20 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.