Rails' inflections are messy

One thing that have always bothered me about the inflector and this pluralize business is that it only work in English. That make rails newbies from non-english speaking countries have a harder time learning the technology than they should. I know ruby’s keywords are already in English, and so are method names and so on. But reading a foreing language is easier; and so is using already defined names. However, a person who doesn’t know English very well will not do a good job in naming his own variables and models in English. A famous quote from computer science field goes: “There are only two hard things in Com­puter Sci­ence: cache in­val­i­da­tion and nam­ing things”. Imagine naming it in a language you aren’t proficient.

Perhaps inflection should not be the default. Maybe it should be optional. If you want it, then you can load your language’s inflection gem, if it’s available.

I don’t think that’s really a good option. Some Rails internals already rely heavily upon the inflections; there have to be some pluralizations loaded by default (whether from within the framework, or an inflections gem). If they WERE to be extracted into a gem (which is what I did), it would still need to be bundled by default. Inflections are used in routing, mapping between models and controllers, and a lot of other places within Rails. They need to be there.

Maybe I’m missing something, but couldn’t the default inflection just don’t do anything? That is, the plural of any word is the word itself. From the user point of view, it would be like there is no pluralization at all.

Cheers

Rails itself depends on pluralization for the reasons I stated in my last message.

I just ran into this again. I attempted to call a model "Media", and the scaffold decided that I meant "Medium", which is NOT a newspaper; it's someone who has a seance. As I often do in that situation, I deleted those files and changed the name to "MediaOutlet" so it would act predictably.

Here's what would be nice to happen:

model: Media controller: media_controller route: /media, media_path, media_new_path, etc... params: params['media']['etc']

That beats having to call pluralize and singularize all the time and try to keep it straight.

This is especially important for constructing stuff in javascript because the easiest thing is to just assume it is normal and add an 's'.

I just ran into this again. I attempted to call a model “Media”, and

the scaffold decided that I meant “Medium”, which is NOT a newspaper;

it’s someone who has a seance.

Not to be a jerk, but you’re wrong:

http://en.wiktionary.org/wiki/media#Etymology_2

As I often do in that situation, I

deleted those files and changed the name to “MediaOutlet” so it would

act predictably.

And as a side effect, got a model name that makes it way easier to understand what you’re actually representing. Until you clarified it, my first guess was going to be that ‘Media’ was a class representing an audio/video/image file.

Here’s what would be nice to happen:

model: Media

controller: media_controller

route: /media, media_path, media_new_path, etc…

params: params[‘media’][‘etc’]

That beats having to call pluralize and singularize all the time and

try to keep it straight.

For bonus points, how would the new behavior distinguish between the ‘show’ and ‘index’ actions? (currently plural-with-no-args vs. singular-with-one-arg)

I suspect you’re going to face a lot of pushback from all the developers who have managed to “keep it straight”, since your suggestion involves breaking every one of their applications.

–Matt Jones

Agreed on all counts. I don’t think pluralization needs to go anywhere. I think the resourceful routes and controller names are more representative of what’s going on. I just think the pluralization rules need to be cleaner and that the backwards compatibility excuse doesn’t work so well for a major 4.0 release.

index: GET /media show: GET /media/1 edit: GET /media/1/edit create: POST /media update: PUT /media/1 new: GET /media/new delete: DELETE /media

I wasn't suggesting changing this retroactively, I was supporting the idea of the inflections gem, which would allow an replacement that didn't require duplicating all the rules in javascript.

Guys, lets keep in mind that I meant for this discussion to be about how the inflection rules themselves are bad. Not how they’re used internally with Rails, but how the file that defines these rules is an utter mess.