Tz Time plugin
Plugin details
Documentation
ruby script/plugin install http://dev.rubyonrails.com/svn/rails/plugins/tztime/
TzTime is subversive. It even _sounds_ subversive, like sharp incisors snicking together in the dark. It sneaks into your app from the inside and stuffs time zone support into the cracks. It's like a little ruby-colored rat, poking around in the under-basement of your code, but instead of chewing away at the infrastructure with its sharp little teeth (and believe me, they _are_ sharp), it builds fluffy (and oh, so comfortable!) little time-zone flavored nests wherever it can.
This look familiar?
class TasksController < ApplicationController def create task = account.tasks.build(params[:task]) task.alert_at = current_user.time_zone.local_to_utc(task.alert_at) task.save! end end
Oh, that awful bloating sensation! Because the time zone is not globally accessible, you have to jump through hoop and ungainly hoop in your controllers...or pass the unfortunate time zone to method after method.
No more! Let the Rodent of Unusually Fine TZ Acumen aid you:
class ApplicationController < ActionController:Base around_filter :set_timezone private def set_timezone TzTime.zone = current_user.time_zone yield TzTime.reset! end end class Task < ActiveRecord::Base tz_time_attributes :alert_at end class TasksController < ApplicationController def create task = account.tasks.create(params[:task]) end end
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: scott, 4 months ago

