Home > Ruby on Rails > Pluralize table names – no thanks!

Pluralize table names – no thanks!

4 April, 2006

Sorry I just can’t live with plural table names, I just can’t get my head around it! Luckily it is easily turned off. In RadRails there is a simple tick box when creating the project which simply adds the following line to the end of your applications config/environment.rb file:

# Include your application configuration below
ActiveRecord::Base.pluralize_table_names = false

I may live to regret not embracing plural table names but I doubt it!

Advertisements
Categories: Ruby on Rails
  1. 25 May, 2006 at 12:55 am

    Right-on. Not only is it just a dumb idea (why would you want to make your framework parse english?), most DBA’s will agree that the name of a table should refer directly to what one record in that table represents.

    Thanks for letting me know how to turn off this stupid feature.

  2. 25 May, 2006 at 1:13 pm

    Yeah that can be a pretty irritating feature. Easily turned off though so don’t let it put you off rails.

  3. seth
    18 June, 2006 at 9:43 pm

    yup thanks a lot. i was cursing because i have an existing schema. You know with names like TLC_ACR_ONYM_TABLE_WTF and it was hard enough as it was to ‘guess’ what model name would be generated….

  4. cutter
    19 June, 2006 at 10:03 pm

    Thousand blessing on you. After a few hours of trying to figure out what the problem was I found this tip.

  5. Michael
    28 November, 2006 at 2:56 am

    Thank you for this information! A thousand curses on the person who thought plural table names was a good idea!

  6. dc
    12 February, 2007 at 9:36 pm

    plural table names are just about ok, if that was all there was to it. but are the controllers plural too? the classes? maybe the views? maybe a random 50% of them. use a plural when generating scaffolds? it always seems 50:50 and such a waste of cycles to have to think about all the time.

  7. Keybern
    31 March, 2007 at 5:56 pm

    plural table names are a convension for those who think about tables as a collection.

  8. Alwyn
    5 May, 2007 at 12:55 pm

    Unfortunately the simple tick box does nothing except generate an error message stating that it cannot find config/environment.rb even though it exists ….

    Maybe it also had to do with the fact that I needed a symbolic link on my mac from /opt/local/bin/ruby to ruby.exe!!!! for radrails to do anything.

    Thanks for the code above though, I’ll add it manually.

  9. eryna82
    18 March, 2008 at 8:53 am

    thanks for the information.
    it really helps

    like seth, i also work with existing tables in oracle.
    it’s irritating when error “table are not exist” comes out

  10. Chris
    30 March, 2008 at 4:42 am

    Thanks for the tip. I’m new to Rails and I’m glad I don’t have to start pluralizing everything. I did find, unfortunately, that this option is not honored correctly by the new scaffold generator in Rails 2.0.2. It created an index view that references (plural) @things, which is nil because the corresponding controller’s index method creates a (singular) @thing variable. Oh well.

  11. Anonymous
    3 December, 2008 at 11:39 am

    thank you very much

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: