Do initializers in a Rails application run every time someone visits a 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 arrives from Los Angeles at 22:00, do the initializers in the rails application start when people from New York and Los Angeles visit, or do the initializers only start after the server starts in Texas?
The reason I ask is because I used the register expression in the initializer file to change the email settings depending on the time of day at which the application is being visited. Of course, this only makes sense if initializers start when someone visits the site. If they only started when the server started, this would be only one case ...
If this is not the right place for this, or if the initializers start only after starting the server 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
Leahcim
source share