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.saveActiveRecord::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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 >-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
So Rails doesn''t but some one has written a Gem to add it. Thank you, Jeffrey Quoting Roger Pack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---