INCREDULOSITY!

September 20th, 2010

Adding a counter to your models is a nifty little rails feature that requires very little setup. One more reason to revisit these old episodes is a little gem tossed in to episode #23.

The pluralize method. Rails does its pluralizations with the Inflector class. You can read all about it from Amy Hoy:

Rails’ use of pluralization is pretty smart, albeit not perfect. From “person” you get “people,” and “mouse” you get “mice.” If you’re tracking deer, though, watch out for “deers.”

Here are a few of her examples:
Inflector.pluralize('test') => "tests"
Inflector.pluralize('mouse') => "mice"
Inflector.pluralize('geese') => "geeses"
"mouse".pluralize => "mice"
exit 1.ordinalize => "1st"

Amy Hoy is wicked cool and one of my ror rockstar role models.

Wait wait—code AND design chops? INCREDULOSITY!

Entry Filed under: Professional,Railscasts Project,Ruby on Rails

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Pages

Tweets

If you are going to write a swear, spell the damn thing correctly, dammit! ...or is it damnit? damn it? ....aw heck.

About 5 days ago from Liana Leahy's Twitter via Twitter Web App

Meta