Blah Blah Woof Woof

Archived content 2005-2007

The plural of cul-de-sac is culs-de-sac

Posted by Tim Riley Mon, 30 Jan 2006 14:16:00 GMT

Tonight I started building a Ruby on Rails technology demo in order to sharpen some of my skills with the framework. Already I have learnt something – while Rails’ conventions are cool and help you write less code, sometimes you need to supplement them. For example, if you want to add an extra singular/plural pair, used for the names of models, controllers (singular) and tables (plural), add something like the following in config/environment.rb (some examples are in there already commented):


 Inflector.inflections do |inflect|
  inflect.irregular 'nudie', 'nudies'
 end

It is the Inflector that handles the magic of pluralisation in Rails. There is some useful info on its wiki page. You can test this pluralisation online.

Also, be sure to quickly peruse the wiki page about magic field names before creating fields in your database tables.

Comments

Trackbacks

Use the following link to trackback from your own site:
http://vault.openmonkey.com/articles/trackback/42

(leave url/email »)