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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:55:32+00:00 2026-05-27T12:55:32+00:00

Do the initializers in a Rails app run each time someone visits the site?

  • 0

Do the initializers in a Rails app run each time someone visits the site?

For example, if my server is started in Texas at 10 a.m. , and someone visits my site from New York at 1 p.m. and someone visits from Los Angeles at 10 p.m, do the the initializers in a rails application run when the people from New York and Los Angeles visit, or do the initializers only run once I start the server in Texas?

The reason I’m asking is because I was using a case expression in an initializer file to change email settings depending on the time of day that app is visited. This would only make sense of course if the initializers ran when someone visited the site. If they ran only when the server was started then it would only be one case…

If that’s not the right place to do it, or if the initializers only run once the server is started in Texas (for example) then where would you put this code?

case
when Time.now.hour == 0
  ActionMailer::Base.smtp_settings = {
    :user_name => "blahblah@example.com",
    :password => "blahblah",
    :address => "smtp.examplel.com",
    :port => 25,
    :tls => true
  }
when Time.now.hour == 1
  ActionMailer::Base.smtp_settings = {
    :user_name => "blah@example.com",
    :password => "eatshit",
    :address => "smtp.example.com",
    :port => 25,
    :tls => true
  }
end
  • 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-27T12:55:33+00:00Added an answer on May 27, 2026 at 12:55 pm

    Initializers get loaded whenever you start up passenger / mongrel or whatever you are using.

    To set these settings at runtime take a look at Rails: Runtime configuration of ActionMailer?

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

Sidebar

Related Questions

I run several daemons in config/initializers/ when I start my rails app, but I
I'm using rufus-scheduler to run a process every day from a rails server. For
I am having problems deploying a Rails app to Heroku, I can't even run
I am trying to run my tests in my first Rails app using the
I'm learning how to do integration testin on my rails app. I started with
I get this error when I run 'rails g' (my app seems to run
I am using rails version 3.0.3. If I run the server in the development
I have been trying to upgrade my app from Rails 2.3 to Rails 3.
I have turned ActiveRecord off in my Rails app in the environment config: Rails::Initializer.run
http://localhost:3000/genre I'm using Instant Rails, I'm introducing scaffolding for the first time ever. So

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.