Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#4052

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.

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Henrik Nyh
    Henrik Nyh
    • No changes were found…

    February 25th, 2010 @ 11:10 AM

  2. Henrik Nyh
    Henrik Nyh
    • 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.

    February 25th, 2010 @ 11:47 AM

  3. Henrik Nyh
    Henrik Nyh

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

    February 25th, 2010 @ 12:28 PM

  4. tadman
    tadman

    This appears to have been remedied in Rails 2.3.8.

    May 26th, 2010 @ 04:45 PM

  5. Ryan Bigg
    Ryan Bigg
    • State changed from new to resolved
    • Importance changed from to Low

    October 11th, 2010 @ 01:03 AM