Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9104

Show
Ignore:
Timestamp:
03/28/08 01:45:04 (3 months ago)
Author:
gbuesing
Message:

Rails::Initializer#initialize_time_zone raises an error if value assigned to config.time_zone is not recognized. Rake time zone tasks only require ActiveSupport instead of entire environment

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r9102 r9104  
    11*SVN* 
     2 
     3* Rails::Initializer#initialize_time_zone raises an error if value assigned to config.time_zone is not recognized. Rake time zone tasks only require ActiveSupport instead of entire environment [Geoff Buesing] 
    24 
    35* Stop adding the antiquated test/mocks/* directories and only add them to the path if they're still there for legacy reasons [DHH] 
  • trunk/railties/lib/initializer.rb

    r9102 r9104  
    350350    end 
    351351 
     352    # Sets the default value for Time.zone, and turns on ActiveRecord time_zone_aware_attributes. 
     353    # If assigned value cannot be matched to a TimeZone, an exception will be raised. 
    352354    def initialize_time_zone 
    353355      if configuration.time_zone 
    354         Time.zone_default = TimeZone[configuration.time_zone] 
     356        zone_default = TimeZone[configuration.time_zone] 
     357        unless zone_default 
     358          raise "Value assigned to config.time_zone not recognized. Run `rake -D time` for a list of tasks for finding appropriate time zone names." 
     359        end 
     360        Time.zone_default = zone_default 
    355361        if configuration.frameworks.include?(:active_record) 
    356362          ActiveRecord::Base.time_zone_aware_attributes = true 
  • trunk/railties/lib/tasks/misc.rake

    r9074 r9104  
    1010end 
    1111 
     12require 'active_support' 
    1213namespace :time do 
    1314  namespace :zones do 
    1415    desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' 
    15     task :all => :environment do 
     16    task :all do 
    1617      build_time_zone_list(:all) 
    1718    end 
    1819     
    1920    desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' 
    20     task :us => :environment do 
     21    task :us do 
    2122      build_time_zone_list(:us_zones) 
    2223    end 
    2324     
    2425    desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time' 
    25     task :local => :environment do 
     26    task :local do 
    2627      build_time_zone_list(:all, Time.now.beginning_of_year.utc_offset) 
    2728    end