On Wednesday, May 18, 2011 10:56:48 AM UTC-6, fredrated wrote: > > "you will make life easier for yourself if you stick to the Rails > conventions for capitalisation and underscores." > > Actually I was trying to do that. My boss told me (he is also a > newbie) that table names start with a capital letter, though I cannot > find documentation to that effect. > If you can point me to any references to naming conventions I would > appreciate it, thanks. >
Table names are all lowercase by convention (and plural). Model names are singular, capitalized CamelCase. In fact, it is a ruby-wide convention that class names are capitalized CamelCase (not just rails). > > I start each table with "tc_" because I am coming from Drupal where > all tables of all modules are in one database and this is necessary to > prevent name conflicts. > > As for having a prefix, you might be interested in the #table_name_prefix property: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-table_name_prefix This would allow you to have tables named: tc_projects tc_employees tc_periods tc_datum And model classes respectively: class Project < ActiveRecord::Base table_name_prefix = "tc_" end ... class Datum < ActiveRecord::Base table_name_prefix = "tc_" end In order to then DRY up your code a bit, you *might* be able to use an abstract base class: class TcPrefix < ActiveRecord::Base table_name_prefix = "tc_" abstract_class = true end class Project < TcPrefix end ... class Datum < TcPrefix end I haven't tested this to see if this variation works correctly. I'd give a try though. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

