Gantt throwing TypeError

Added by William Wedin about 11 years ago

Hi all. I just got Redmine going on my server this morning, and I'm having some trouble with Gantt. If a project has a ticket and that ticket has a due date, browsing to the Gantt page for that project produces an error. Does anyone have some insight that could point me in the direction of a fix? Thanks!

Here are the details:

TypeError in Issues#gantt

Showing issues/gantt.rhtml where line #192 raised:

can't convert Date into Float

Extracted source (around line #192):

190: i_late_date = [i_end_date,].min if i_start_date <
192: i_left = ((i_start_date - @gantt.date_from)*zoom).floor
193: i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
194: d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
195: l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width

Application Trace

vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:249:in `minus_without_duration'
vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:249:in `minus_without_coercion'
vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:258:in `-'
app/views/issues/gantt.rhtml:192:in `_run_erb_47app47views47issues47gantt46rhtml'
app/views/issues/gantt.rhtml:181:in `each'
app/views/issues/gantt.rhtml:181:in `_run_erb_47app47views47issues47gantt46rhtml'
app/controllers/issues_controller.rb:349:in `gantt'
app/controllers/issues_controller.rb:348:in `gantt'

About your application's environment
Ruby version 1.8.6 (i386-mswin32)
RubyGems version 1.3.1
Rails version 2.1.2
Active Record version 2.1.2
Action Pack version 2.1.2
Active Resource version 2.1.2
Action Mailer version 2.1.2
Active Support version 2.1.2
Application root C:/redmine
Environment development
Database adapter sqlserver
Database schema version 101

Replies (2)

RE: Gantt throwing TypeError - Added by William Wedin about 11 years ago

I did find a solution for this, after debugging it. i_end_date was something like a datetime, which apparently can't be compared with a date. I'm no Ruby expert, but this seems strange to me, double so because no one else seems to have this problem. Nevertheless, it was fixed with the following three lines of code at line 189:

i_start_date = i_start_date.to_date();
i_end_date = i_end_date.to_date();
i_done_date = i_done_date.to_date();

Is this perhaps an artifact of running on Windows?

RE: Gantt throwing TypeError - Added by Łukasz Żbikowski about 11 years ago

Linux has the same problem (RH el5, RM 0.8.4, Database: Oracle, Rails 2.1.2)

Fixed by your code.