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’: UPDATEdspam_token_dataSETspam_hits= 10,
last_hit= ‘2008-03-19’,innocent_hits= 64,token=
3426742412487913678,uid= 1 WHEREuidtoken= NULL
TIA,
Jeffrey