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.

active_support/core_ext/string/inflections doesn't load default inflections

#6460

Requiring 'active_support/core_ext/string/inflections'
doesn't load default inflections (active_support/inflections) in AS 3.0.4 :

When using AS as a standalone library (such as in mail gem, https://github.com/mikel/mail)
this may result in broken String#singularize/String#pluralize methods which can go unnotticed
(the mentionned gem only actually use String#constantize).

Others libraries, such as Sequel, try to use these methods if they are defined instead
of their own implementation, which produces nasty bugs later in the program without any
actual action from the user other than requiring both the mail and sequel libraries.

Is directly loading 'active_support/core_ext/string/inflections' (or indirectly,
via 'active_support/core_ext/string') without defining its own inflections considered bad form,
in which case I may report the problem to the mail author, or should the default
inflections be always loaded ?

(The test suite case for core_ext/string doesn't appear to be affected thanks to an implicit active_support/inflections loading done by one of the explicit requires).

Reported by Guillaume Laville · February 22nd, 2011 @ 09:26 AM

State: invalid
Milestone: 3.x
Assigned to: Dan Pickett Dan Pickett
Importance: Low

Activity

  1. oliland
  2. Serg Podtynnyi
    Serg Podtynnyi

    +1 for solving this issue

    March 10th, 2011 @ 08:39 AM

  3. Dan Pickett
    Dan Pickett

    +1 there should be a consistent and documented mechanism to load default inflections.

    I would think that require "active_support/inflector" would be the desired require statement.

    That appears to properly load the inflections along with the core string extensions.

    March 12th, 2011 @ 04:39 PM

  4. Dan Pickett
    Dan Pickett
    • State changed from new to open
    • Milestone set to 3.x
    • Assigned user set to Dan Pickett
    • Importance changed from to Low

    If no one objects, I don't think this is a bug, and I'd like to close this out.

    I think the require statement in my comment above is what gem authors should be using.

    March 12th, 2011 @ 05:25 PM

  5. Andrew White
    Andrew White

    Agreed - 'active_support/inflector' is the correct require.

    March 12th, 2011 @ 09:33 PM

  6. Dan Pickett
    Dan Pickett
    • State changed from open to invalid

    March 12th, 2011 @ 10:36 PM