# Using TzTime with timezone_fu.
# Untested, theoretical code only.
class ApplicationController < ActionController::Base
around_filter :set_timezone
private
def set_timezone
TzTime.zone = current_user.time_zone
yield
TzTime.reset!
end
end
class Event < ActiveRecord::Base
has_timezone :fields => [ :start_datetime, :end_datetime]
# timezone_fu expects a timezone method to return the TzInfo timezone string
def timezone
TzTime.zone.name
end
end
# Or, you could do it like this too, if you didn't care about TzTime
# or the logged in user, but instead wanted to use a relationship
class Event < ActiveRecord::Base
has_timezone :fields => [ :start_datetime, :end_datetime]
belongs_to :user
delegate :timezone, :to => :user
end