How to do composite primary keys with FactoryGirl Gem
Asked Answered
T

0

6

How to do composite keys using FactoryGirl with below relationship

Portal(uuid, name)

listing(uuid, portal_uuid, name)

location(uuid, portal_uuid)

in here listing and location has composite primary key (uuid, portal_uuid).

I have tried different kind of ways but can't solve it. Have anyone met this problem, pls help?

Tartu answered 29/3, 2012 at 9:1 Comment(3)
Have you solved this problem?Cytherea
I'm not sure I understand exactly how your models are related. It would probably help if you could post some of your model code.Divestiture
Error using AR v3, FG v4, composite_primary_keys v5 > ActiveRecord::StatementInvalid: > PG::UndefinedColumn: ERROR: column "col1,col2" does not exist > LINE 1: ...") VALUES ($1, $2, $3) RETURNING "col1... Code: > class Table1 < ActiveRecord::Base > self.primary_key = :col1 > end > > class Table2 < ActiveRecord::Base > self.primary_key = :col2 > end > > class TableRelation < ActiveRecord::Base > require 'composite_primary_keys' > self.primary_keys = :col1, :col2 > endEinsteinium

© 2022 - 2024 — McMap. All rights reserved.