I want a has_many relationship described below
class User < ActiveRecord::Base
has_many :mcollections, :foreign_key=>'obj_id'
end
Below is definition of table mcollections
create table mcollections (
id int not null auto_increment,
obj_id varchar(255) not null,
category varchar(255) not null,
);
The :foreign_key
is NOT A SINGLE FIELD on table mcollections
. Foreign key has to be a combination of 2 fields (obj_id + category
). How can I specify this in User
class?