I am using Ruby 1.8.7 and Rails 3.0.3. Even though currently all of my users are in the same time zone as my server, I thought that in preparation for world domination I’d get rid of all of my RubyTimeObjIGotOutOfMyDb.getlocal calls and replace them with RubyTimeObjIGotOutOfMyDb.in_time_zone(user_timezone) where the user’s timezone is a column in my user’s table. What happened is now my page takes maybe 5 or 6 times as long to load. Is this the wrong strategy? Is there a better way I should be preparing for users in different timezones from my server?
I am using Ruby 1.8.7 and Rails 3.0.3. Even though currently all of my
Share
watching this railscast
I think you just need to do
controllers/application.rb
And all the times will be converted when fetching from db
If times are not in the current timezone, try this in the views (or in console for testing)
UPDATE:
If you are doing that call
in_time_zone(zone)many times, I think it’s fetching the corresponding time difference many times, the way the screencast tells to do, it will fetch only one time and use it in every conversion.