Rails by default uses a system-generated primary key called “id” for all persisted objects. I personally like this (for the very reasons Dave Thomas outlines in the Rails book on pp. 286-287), but if you don’t, you can change it. Like Dave, I don’t recommend it, but here’s how if you must.
class Friend […]
Archive for April, 2008
Rails Tip: Primary Keys
Rails Tip: Overriding Defaults in ActiveRecord
Have you ever wish you could tell Rails the name of the table that mapped to your model class? Perhaps you want a model to represent a legacy table (which could be any table that already exists which is either too painful to recreate or over which you have no control). Or perhaps you just […]
Rails Tip: Using ActiveRecord Outside Rails
I have found as I’ve been working on my project that Rails has many very useful little features that may not be used all that often but are sometimes needed. As I come across them I hope to note them here in the hopes that they will help someone (myself included) at some point.
Yesterday […]
Filed in: Rails

