lundi 14 septembre 2015

ActiveRecord w/o Rails and existing ID column

I have an existing Sqlite table that's got an id column, but it's not the primary key. The primary key is named ROWID.

So in my model I've done:

  self.primary_key = "ROWID"

However, because the id field actually has good data in, AR is overwriting that data when it instantiates the records with the value from ROWID.

How do I go about preserving the value in the id column, while indicating ROWID is the primary key?

Aucun commentaire:

Enregistrer un commentaire