Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the Rails Inflector module deprecated?

I looked in the Rails docs under inflector and found this message...

Module deprecated

This module is deprecated on the latest stable version of Rails. The last existing version (v2.1.0) is shown here.

There was no explanation or reference to any further detail.

I recalled seeing a Rails Trac website. I hunted that down and found that it too is deprecated. It referred me to Lighthouse.

I found some info there -- the Rails core team is not accepting patches for inflections.rb. But it didn't really explain the deprecation message. What is the story behind that?

like image 610
Ethan Avatar asked Jan 26 '09 21:01

Ethan


3 Answers

You might take a look at this post for an explanation.

like image 92
Joe Soul-bringer Avatar answered Nov 18 '22 19:11

Joe Soul-bringer


I'm looking at the Edge Rails source code for inflector.rb right now and I can't see anything to say that it's deprecated—where did you get that information from?

Patches aren't being accepted because they might break legacy code that's relying on incorrect inflections. You can add your own rules by accessing the singleton instance yielded by Inflector.inflections, as shown below:

ActiveSupport::Inflector.inflections do |inflect|  
  inflect.irregular 'person', 'people'
  inflect.uncountable 'rails'
end
like image 4
John Topley Avatar answered Nov 18 '22 18:11

John Topley


Two separate issues at play. Inflections won't be patched to correct errors to protect legacy uses of incorrect inflections but more importantly inflections was moved into ActiveSupport as of 2.2.1

see 2.2.1 here versus pre 2.2.1 here

like image 2
srboisvert Avatar answered Nov 18 '22 18:11

srboisvert