Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5: Calling to_s on a BigDecimal results in an infinite loop #280

Closed
benpritchard opened this issue Feb 10, 2016 · 4 comments
Closed

Comments

@benpritchard
Copy link

def to_s_with_default_format(format = 'F')

class BigDecimal

  def to_s_with_default_format(format = 'F')
    to_s_without_default_format(format)
  end
  alias_method :to_s_without_default_format, :to_s
  alias_method :to_s, :to_s_with_default_format

end

With rails 5.0.0.beta2, calling to_s on a BigDecimal and xeroizer installed results in an infinite loop.

Sample backtrace:

     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/xeroizer-2.16.1/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/xeroizer-2.16.1/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/xeroizer-2.16.1/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/xeroizer-2.16.1/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/xeroizer-2.16.1/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'

     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/xeroizer-2.16.1/lib/big_decimal_to_s.rb:4:in `to_s_with_default_format'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/big_decimal/conversions.rb:9:in `to_s'
     # /Users/ben/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/core_ext/numeric/conversions.rb:126:in `to_s'

This seems to be the commit that changed things: rails/rails@f61dd4f

@Schwad
Copy link

Schwad commented Aug 3, 2016

Got this same issue, thanks for the fix.

@bendangelo
Copy link

Thanks for the fix.

@Rio517
Copy link

Rio517 commented Aug 26, 2016

Now if we could just get the version bummed up so folks aren't running around trying to figure out why their upgraded app is so freaking slow. Thanks!

@SylarRuby
Copy link

Oh. Where're the fix? #317

@rjaus rjaus closed this as completed Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants