Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#3972

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.

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Raimonds Simanovskis
    Raimonds Simanovskis

    Updated patch to also include correct condition for DateTime#to_datetime method definition.

    February 16th, 2010 @ 08:15 PM

  2. Greg Campbell
    Greg Campbell

    This patch appears to work, except that without the shim we now need to explicitly require active_support/core_ext/file/path for test/core_ext/file_test.rb to pass. I've attached a second patch which does only that.

    April 13th, 2010 @ 07:54 AM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from new to resolved

    Greg, I don't see how that patch relates to this issue. I'm going to close this ticket and hope you've attached that patch to the right ticket.

    June 12th, 2010 @ 02:54 AM

  4. Raimonds Simanovskis
    Raimonds Simanovskis

    This patch was applied to master branch therefore it's OK to close this ticket
    http://github.com/rails/rails/commit/5fcaf917612c61174f55bbd2301131...

    June 19th, 2010 @ 08:00 AM