下記の has_many 関係が欲しい
class User < ActiveRecord::Base
has_many :mcollections, :foreign_key=>'obj_id'
end
以下はテーブルmcollectionsの定義です
create table mcollections (
id int not null auto_increment,
obj_id varchar(255) not null,
category varchar(255) not null,
);
は:foreign_key
テーブルの単一フィールドではありませんmcollections
。外部キーは 2 つのフィールド ( obj_id + category
) の組み合わせである必要があります。User
これをクラスでどのように指定できますか?