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/parameterize incorrectly assumes you have set $KCODE='u'

#2308

I'm developing a plugin which uses the AS method parameterize to create a url-like string. When I try to test the plugin, all tests result in the error undefined method ´normalize´ for ´whatever´:String. I'm using files created by script/generate plugin, so all should be correct, aside from the problem described by Ticket #1878.

Then I realize the problem was that active_support/multibyte wasn't being loaded for some reason. The reason is actually you have to set $KCODE = 'u' manually in your tests to force AS to load multibyte.

To reproduce de error, try to run this to simple scripts (I'm using ruby 1.8.7)


# Will fail with undefined method error
require 'rubygems'
require 'active_support'
puts "some random string".parameterize

# Will work
$KCODE = 'u'
require 'rubygems'
require 'active_support'
puts "some random string".parameterize
# => 'some-random-string'

I think this either an incorrect behavior of parameterize (it should skip 'normalize' if it's not defined) or an incorrect use of KCODE in active_support which I thought it was by default set to 'u' since the latter versions of Rails 1.x.

Reported by Markús · March 21st, 2009 @ 11:55 AM

State: invalid
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  2. Norman Clarke
    Norman Clarke
    • Tag changed from 2.x, activesupport to 2.x, activesupport, invalid

    This is no longer the case after my recent changes to Inflector; normalize was moved to the Unicode module and is invoked directly as Unicode.normalize rather than through the proxy as before.

    You can verify this by running the following code under 1.8.7 or 1.9.x:

    # encoding: utf-8
    require "rubygems"
    # gem "activesupport", "3.0.0.beta3"
    require "active_support/inflector"
    p "olá mundo!".parameterize    #=> "ola-mundo"
    

    May 29th, 2010 @ 09:55 PM

  3. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid
    • Importance changed from to

    July 28th, 2010 @ 10:26 AM