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

Changeset 788

Show
Ignore:
Timestamp:
02/24/05 12:00:42 (4 years ago)
Author:
david
Message:

Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck]

Files:

Legend:

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

    r768 r788  
    11*SVN* 
     2 
     3* Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck] 
    24 
    35* Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes: 
  • trunk/activerecord/lib/active_record/timestamp.rb

    r773 r788  
    2020       
    2121    def create_with_timestamps #:nodoc: 
    22       t = timestamps_gmt ? Time.now.gmtime : Time.now 
     22      t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now ) 
    2323      write_attribute("created_at", t) if record_timestamps && respond_to?(:created_at) && created_at.nil? 
    2424      write_attribute("created_on", t) if record_timestamps && respond_to?(:created_on) && created_on.nil? 
     
    3131 
    3232    def update_with_timestamps #:nodoc: 
    33       t = timestamps_gmt ? Time.now.gmtime : Time.now 
     33      t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now ) 
    3434      write_attribute("updated_at", t) if record_timestamps && respond_to?(:updated_at) 
    3535      write_attribute("updated_on", t) if record_timestamps && respond_to?(:updated_on) 
     
    4545    @@record_timestamps = true 
    4646    cattr_accessor :record_timestamps 
     47 
     48    # deprecated: use ActiveRecord::Base.default_timezone instead. 
    4749    @@timestamps_gmt = false 
    48     cattr_accessor :timestamps_gmt 
     50    def self.timestamps_gmt=( gmt ) #:nodoc: 
     51      warn "timestamps_gmt= is deprecated. use default_timezone= instead" 
     52      self.default_timezone = ( gmt ? :utc : :local ) 
     53    end 
     54 
     55    def self.timestamps_gmt #:nodoc: 
     56      warn "timestamps_gmt is deprecated. use default_timezone instead" 
     57      self.default_timezone == :utc 
     58    end 
    4959  end 
    5060end 
  • trunk/activerecord/test/base_test.rb

    r527 r788  
    710710  def test_define_attr_method_with_value 
    711711    k = Class.new( ActiveRecord::Base ) 
    712     k.define_attr_method :table_name, "foo" 
     712    k.send(:define_attr_method, :table_name, "foo") 
    713713    assert_equal "foo", k.table_name 
    714714  end 
     
    716716  def test_define_attr_method_with_block 
    717717    k = Class.new( ActiveRecord::Base ) 
    718     k.define_attr_method( :primary_key ) { "sys_" + original_primary_key } 
     718    k.send(:define_attr_method, :primary_key) { "sys_" + original_primary_key } 
    719719    assert_equal "sys_id", k.primary_key 
    720720  end