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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Timor Tsentsiper

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/47521389-5d13-4c3e-b18f-6a1cee5edc86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Sasha Boginsky
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:

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/caac10e0-44ef-4bd2-a50c-d7ff22a5a3aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Sasha Boginsky
In reply to this post by Timor Tsentsiper
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!

On Friday, May 25, 2018 at 2:37:17 AM UTC-4, Timor Tsentsiper wrote:

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bfcbfa78-4ff2-4301-85b5-f43e6f327619%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.