This project is archived and is in readonly mode.

#2308 ✓invalid
Markús

ActiveSupport/parameterize incorrectly assumes you have set $KCODE='u'

Reported by Markús | March 21st, 2009 @ 11:55 AM | in 3.x

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.

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Norman Clarke

    Norman Clarke May 29th, 2010 @ 09:55 PM

    • 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"
    
  • Rohit Arondekar

    Rohit Arondekar July 28th, 2010 @ 10:26 AM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “”

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages