[Nitro] Nitrous blog category and categories

George Moschovitis george.moschovitis at gmail.com
Sun Sep 9 03:33:20 EDT 2007

> I think the Rails convention of tablename := pluralized modelname is
> like so totally Yuck-O-la.

Hello Robert,

Og uses singular for table names. And we use  singular for all directories.

     app.dispatcher.root.comments = Comment
>      app.dispatcher.root.categories = Category

this has nothing to do with the database or the tables. A plural is used
here to provide standard REST urls:

/comments -> lists the comments
/comments/view/1 -> view comment 1

it makes not much sense to use /comment to list all comments. However, since
we use singular in all other places in Nitro/Og, for some time now I am
thinking to use singular even on controller mount points. This is a personal
decision though.

The important thing is that Nitro/Og uses singular throughout, but allows
the  developer to override this (as is the case in the Blog example: the
developer (me) decided to use plural names as mount points)


I had to add a "to_link" method to the models to get the demo to run.
> In category.rb I added
> class Category
>   def to_link
>       "<a href='/category/view/#{oid}'>#{title}</a>"
>   end
> ... but the dispatcher path is /categories/!  D'oh!
> And in Rails we type "Category.find" to get many categories from a table
> full of categories....
> The morphology of pluralization is an artifact of the European grammars
> burned into our brains.  Think of Japanese.   Would a Japanese
> programmer be at any disadvantage for the lack of pluralization in her
> table names?
> Heck, case and gnarly verb conjugations are part of how we think.   We
> don't add those to our programming conventions ( except in variable
> names ).   So why bother with plurals, when
> 1) the information it's intended to convey is already clear from context
> 2) It's excess code
> 3) It's complicated
>   -- elk -> elk
>   -- does it do latin?
>   -- Is it available in Finnish
>   -- what about the languages where it's a no-op?
> 4) It introduces inconsistencies in usage ( Category.find -- looks in a
> group of many categories, may return many categories... etc.)
> I bet the reason plurals are part of the convention is because...uh,
> because we can.  A few simple rules, and a dictionary for the
> exceptions....
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20070909/4beac6f8/attachment.html 

More information about the Nitro-general mailing list