This project is archived and is in readonly mode.
Date.end_of_week not working in production mode
-
Jeff Kreeftmeijer
I was unable to reproduce this on master:
$ script/rails c 13.Loading development environment (Rails 3.0.0) >> 13.days => 13 days >> exit $ script/rails c production Loading production environment (Rails 3.0.0) >> 13.days => 13 days >> exit -
Rafael Mendonça França
I was unable to reproduce this on rails 3.0.0:
$ script/rails c >> a = Date.new(2010,9,30) => Thu, 30 Sep 2010 >> a.end_of_week => Sun, 03 Oct 2010 >> exit $ script/rails c production Loading production environment (Rails 3.0.0) >> a = Date.new(2010,9,30) => Thu, 30 Sep 2010 >> a.end_of_week => Sun, 03 Oct 2010 >> exit -
David Trasbo
Neither was I:
➜ script/rails c Loading development environment (Rails 3.1.0.beta) ruby-1.9.2-p0 > a = Date.new(2010, 9, 30) => Thu, 30 Sep 2010 ruby-1.9.2-p0 > a.end_of_week => Sun, 03 Oct 2010 ruby-1.9.2-p0 > exit ➜ script/rails c production Loading production environment (Rails 3.1.0.beta) ruby-1.9.2-p0 > a = Date.new(2010, 9, 30) => Thu, 30 Sep 2010 ruby-1.9.2-p0 > a.end_of_week => Sun, 03 Oct 2010 ruby-1.9.2-p0 > exit(Edge Rails).
-
Andrew White
- State changed from new to invalid
- Importance changed from to Low
Closing as no-one seems to be able to reproduce (myself included).
-
Roger Campos
I just realize now that, as you all say, it's working properly with a new rails 3.0.0 application, my mistake.
However I'm still having this wired behaviour with an app I'm currently working on (http://github.com/Itnig/intranet3). Tested with ubuntu and mac platforms I was unable to reach the source of this problem.
Anyway, looking at the implementations of end_of_week and beginning_of_week methods in activesupport/lib/active_support/core_ext/date/calculations.rb I still believe that 'result = self + days_to_sunday.days' (line 180) should be replaced with 'result = self + days_to_sunday'.
The same change has already been made in beginning_of_week method, symetrical of end_of_week. -
Yuri Tomanek
I am also getting this error.
Loading production environment (Rails 3.0.0) irb(main):001:0> 13.days => 1123200 irb(main):002:0> a = Date.new(2010,9,30) => Thu, 30 Sep 2010 irb(main):003:0> a.end_of_week => Mon, 31 May 2720Though this is happening in both development and production environments.
I have tested on an OSX machine and also Linux box with same results.
Im using ruby 1.8.7 (2009-06-12 patchlevel 174) on both machines. -
Andrew White
Still can't reproduce this using the system ruby on Mac OS X. Looking at your irb output it seems as though 13.days is returning an integer instead of a duration. Is there a plugin or gem that may have overwritten the days method? The other possibility is an old version of ActiveSupport::CoreExtensions::Numeric::Time being included - in Rails 1.2.x it returns an integer and not a duration.
-
Yuri Tomanek
I will look into the possibility that a gem or plugin is overriding the days method.
The weird thing is that this only started happening tonight, no new gems or plugins we added but I did do 3 small changes to the app, Though I would not expect those changes to effect the days method nor override it. -
Yuri Tomanek
Oh I lied!
I did add a new gem to my Gemfile, I just did it late last night and had not got around to deploying the changes.
God was the culprit, not that I can remember why I wanted to add it to my Gemfile.
It was a long one last night.Thanks for putting me on the right track.
-
Roger Campos
You were right, the 'god' gem (god-0.11.0) was causing the problem redefining .days method in /lib/god/sugar.rb:20.
Thanks for your advice, finally solved!