This project is archived and is in readonly mode.

#3972 ✓resolved
Raimonds Simanovskis

[PATCH] DateTime#to_date returns self when Date#to_date is defined at first

Reported by Raimonds Simanovskis | February 16th, 2010 @ 07:57 PM

On Ruby 1.8.7 DateTime#to_date returns self due to the following bug.

As active_support/time.rb loads active_support/core_ext/date/conversions before active_support/core_ext/date_time/conversions then DateTime#to_date method is not defined as DateTime.method_defined?(:to_date) is true as Date#to_date method is already defined and DateTime inherits to_date method from Date.

There is similar issue with DateTime#xmlschema method definition.

Included patch fixes conditions for DateTime#to_date and DateTime#xmlschema definition to check if method is defined for DateTime and is not just inherited. Included patch also removes requiring 'active_support/ruby/shim' in abstract_unit.rb when using Ruby 1.8.7 to ensure the same sequence of requires as in real Rails applications.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by