Column names restrictions

Last update – 2006-05-30

Ruby on Rails praises convention over configuration. Nice, but You have to be aware of this conventions, or You may run into troubles. Let’s take DB column names. RoR makes many assumptions about them, allowing this way many magic things happen.

Currently I’m aware of following conventions:

  • column id is reserved for table primary index
  • suffix _at for datetime fields
  • suffix _on for date field
  • suffix _id for reference to other table
  • column type single table inheritance (see: RoR Wiki)
  • dont use sessions table in DB (or don’t use code generated by scaffold) details explained

I was not aware about type column, and doing application for import scan results from Nessus I ran on following error:

SyntaxError ((eval):1:in `compute_type': compile error
(eval):1: parse error, unexpected tINTEGER

It was caused by type column, since DB structure was tailored to match Nessus export to SQL file, which was using such a column.

Columns named created_on and updated_at are automagically set for record creation date and update time respectively

Join the Conversation


  1. Pingback: ??????????
Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.