Legacy DB table with double primary key

I have a legacy MySQL table with a double key:

describe amethyst_development.dspam_token_data;
±--------------±---------------------±-----±----±-----------±------+
| Field | Type | Null | Key | Default | Extra |
±--------------±---------------------±-----±----±-----------±------+
| uid | smallint(5) unsigned | NO | PRI | 0 | |
| token | bigint(20) unsigned | NO | PRI | | |
| spam_hits | int(11) | NO | | 0 | |
| innocent_hits | int(11) | NO | | 0 | |
| last_hit | date | NO | | 0000-00-00 | |
±--------------±---------------------±-----±----±-----------±------+

How do I define the primary key in the model class?

class Token < ActiveRecord::Base
set_table_name ‘dspam_token_data’
set_primary_key [‘uid’, ‘token’]
end

Gives the error:

t.save
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ‘uidtoken’
in ‘where clause’: UPDATE dspam_token_data SET spam_hits = 10,
last_hit = ‘2008-03-19’, innocent_hits = 64, token =
3426742412487913678, uid = 1 WHERE uidtoken = NULL

TIA,
Jeffrey

maybe google ‘ruby composite keys’?

How do I define the primary key in the model class?

class Token < ActiveRecord::Base
set_table_name ‘dspam_token_data’
set_primary_key [‘uid’, ‘token’]
end

So Rails doesn’t but some one has written a Gem to add it.

Thank you,
Jeffrey

Quoting Roger P. [email protected]: