This project is archived and is in readonly mode.

#4052 ✓ resolved
Henrik Nyh

ActiveSupport breaks literal "%%" in non-hash String interpolation

Reported by Henrik Nyh | February 25th, 2010 @ 11:09 AM

This works in regular Ruby 1.8 IRB:

>> "%d%%" % 123
=> "123%"

But with ActiveSupport:

>> "%d%%" % 123
ArgumentError: one hash required

It seems ActiveSupport attempts to emulate Ruby 1.9 string interpolation, but in doing so, it effectively breaks "%%" when you're not interpolating with a hash.

Will write patch shortly.

Comments and changes to this ticket

  • Henrik Nyh

    Henrik Nyh February 25th, 2010 @ 11:10 AM

    • no changes were found...
  • Henrik Nyh

    Henrik Nyh February 25th, 2010 @ 11:47 AM

    • Tag changed from string interpolation, activesupport, active_support, interpolation, ruby1.9 to string interpolation, activesupport, active_support, interpolation, patch, ruby1.9

    When I run the tests, it seems the i18n gem is used for the actual interpolation. Apparently this issue has been fixed in the i18n gem on GitHub (http://github.com/svenfuchs/i18n/commit/bd740600683ca2aae78e4abf898.... That version of the gem does not appear to be published.

    It's still not fixed in ActiveSupport proper, and since the i18n gem is used for interpolation in the ActiveSupport tests, at least the way I ran them, I'm not sure what the best course of action is. Should this functionality exist in both places? Should the tests be modified to actually test the ActiveSupport version? Did I run the tests wrong?

    Either way, I made a patch, then ran the tests with that part of the i18n gem commented out, so that when this code actually runs, it does work.

  • Henrik Nyh

    Henrik Nyh February 25th, 2010 @ 12:28 PM

    Monkeypatch initializer until this is applied: http://gist.github.com/314504

  • tadman

    tadman May 26th, 2010 @ 04:45 PM

    This appears to have been remedied in Rails 2.3.8.

  • Ryan Bigg

    Ryan Bigg October 11th, 2010 @ 01:03 AM

    • State changed from “new” to “resolved”
    • Importance changed from “” to “Low”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

People watching this ticket

Attachments

Referenced by

Pages