Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

inflections not working with activesupport 3.2.3 ? #6514

Closed
hadmut opened this Issue · 1 comment

2 participants

@hadmut

Hi,

on all my machines with versions of activesupport up to 3.2.2 the following code was working as expected:

ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'zaehlmarke', 'zaehlmarken'
inflect.irregular 'texturl' , 'texturls'

end

puts "zaehlmarke".pluralize

However, I just wanted to run the same code on a new machine and got activesupport 3.2.3 there, and the problem:

Error undefined method `pluralize' for "zaehlmarke":String
NoMethodError

and rails does not find the tables since it used wrong inflections (regular english instead of the defined irregular ones).

regards

@carlosantoniodasilva

Apparently it works fine, with a copy & past of your code in a sample app:

Loading development environment (Rails 3.2.3)
>> ActiveSupport::Inflector.inflections do |inflect|
?>   inflect.irregular 'zaehlmarke', 'zaehlmarken'
>>   inflect.irregular 'texturl' , 'texturls'
?> end
=> [[/(t)exturls$/i, "\\1exturl"], [/(z)aehlmarken$/i, "\\1aehlmarke"], [/(z)ombies$/i, "\\1ombie"], [/k(?i)ine$/, "cow"], [/K(?i)ine$/, "Cow"], [/(m)oves$/i, "\\1ove"], [/(s)exes$/i, "\\1ex"], [/(c)hildren$/i, "\\1hild"], [/(m)en$/i, "\\1an"], [/(p)eople$/i, "\\1erson"], [/(database)s$/i, "\\1"], [/(quiz)zes$/i, "\\1"], [/(matr)ices$/i, "\\1ix"], [/(vert|ind)ices$/i, "\\1ex"], [/^(ox)en/i, "\\1"], [/(alias|status)es$/i, "\\1"], [/(octop|vir)i$/i, "\\1us"], [/(cris|ax|test)es$/i, "\\1is"], [/(shoe)s$/i, "\\1"], [/(o)es$/i, "\\1"], [/(bus)es$/i, "\\1"], [/(m|l)ice$/i, "\\1ouse"], [/(x|ch|ss|sh)es$/i, "\\1"], [/(m)ovies$/i, "\\1ovie"], [/(s)eries$/i, "\\1eries"], [/([^aeiouy]|qu)ies$/i, "\\1y"], [/([lr])ves$/i, "\\1f"], [/(tive)s$/i, "\\1"], [/(hive)s$/i, "\\1"], [/([^f])ves$/i, "\\1fe"], [/(^analy)ses$/i, "\\1sis"], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, "\\1\\2sis"], [/([ti])a$/i, "\\1um"], [/(n)ews$/i, "\\1ews"], [/s$/i, ""]]
>> 
?> puts "zaehlmarke".pluralize
zaehlmarken
=> nil

The error Error undefined method 'pluralize' for "zaehlmarke":String is not because inflections are not working, but because ActiveSupport may not be required / properly initialized yet:

$ irb
>> ''.pluralize
NoMethodError: undefined method 'pluralize' for "":String
>> require 'active_support/all'
=> true
>> ''.pluralize
=> ""

Make sure to check if everything is being loaded properly , and if you're still getting errors, please post more code examples and a stack trace, as well as your ruby version.

Thanks!

As a side note, you shouldn't be getting Rails 3.2.2 in one deployment machine and 3.2.3 in another, unless you explicitly wanted to test that (this was not clear to me in your post).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.