TypeError: ActiveSupport::Duration can't be coerced into Fixnum

82 views
Skip to first unread message

Timor Tsentsiper

unread,
May 25, 2018, 2:37:17 AM5/25/18
to Ruby on Rails: Talk

I Just upgraded old rails app (3.2.22) to rails 4.2.10 and I am not sure if this is the right place but after a few hours of research, I am a little stumped. BRAND NEW rails 4.2.10 (same ruby) projects work (the behavior below does not happen) but this upgraded project fails on any instance of the ActiveSupport:: Duration functions. Did I miss something in the upgrade? Is it a gem issue? load order?

its not just Fixnum its any of these ActiveSupport::Duration functions

Expected behavior

irb(main):001:0> 20.days
=> 20 days
irb(main):002:0> 20.days.from_now
=> Wed, 13 Jun 2018 22:35:42 UTC +00:00

Actual behavior

irb(main):003:0> 20.days
TypeError: ActiveSupport::Duration can't be coerced into Fixnum
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/time.rb:35:in `*'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/time.rb:35:in `days'
	from (irb):3
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'
irb(main):004:0> 20.days.from_now
TypeError: ActiveSupport::Duration can't be coerced into Fixnum
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/time.rb:35:in `*'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/time.rb:35:in `days'
	from (irb):4
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /Users/ttsentsiper/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

System configuration

Rails version: 4.2.10

Ruby version: ruby 2.3.1p112

I also tried upgrading to ruby 2.4 on the same project and the issue persists (seems not ruby related)
Also copied the gemfile from the project that does not work into a new project and things seem ok

Sasha Boginsky

unread,
Feb 7, 2019, 9:31:52 AM2/7/19
to Ruby on Rails: Talk
Hey, I just fixed this issue when upgrading from ruby 2.1.2 to 2.4.4 on Rails 3.2.22. the solution you are looking for can be found here:


you might run into a new error from the solution, and the solution to that can be found here:


 Hope that helps!

Sasha Boginsky

unread,
Feb 7, 2019, 9:31:52 AM2/7/19
to Ruby on Rails: Talk
I just updated Ruby in my application from 2.1.2 to 2.4.4 and am now receiving the same errors. Using Rails 3.2.22.5 and have not changed that. Maybe that could help you figure it out. Also looking into it right now so please let me know if you do! 


On Friday, May 25, 2018 at 2:37:17 AM UTC-4, Timor Tsentsiper wrote:
Reply all
Reply to author
Forward
0 new messages