lib/greenwich/rails.rb in greenwich-0.0.2 vs lib/greenwich/rails.rb in greenwich-0.0.3
- old
+ new
@@ -50,10 +50,11 @@
def time_zone(name, options = {})
options[:for] = [options[:for]].compact unless options[:for].is_a? Array
options[:for].map! { |v| [v, Greenwich::Utilities.get_time_field(v, column_names)] }
define_method "#{name}" do
- ActiveSupport::TimeZone.new(read_attribute(name))
+ time_zone_name = read_attribute(name)
+ ActiveSupport::TimeZone.new(time_zone_name) unless time_zone_name.nil?
end
define_method "#{name}=" do |time_zone|
instance_eval do
time_zone = ActiveSupport::TimeZone.new(time_zone) unless time_zone.is_a? ActiveSupport::TimeZone || time_zone.nil?