factory for a model with no id or primary key

615 views
Skip to first unread message

Eric Theise

unread,
Sep 28, 2011, 7:56:38 PM9/28/11
to factory_girl
Good afternoon,

I've been sailing along for a few days without incident, but today I
hit a blocker. In trying to create a factory for a table that is used
to validate values for another table, I hit this error (from
PostgreSQL c/o Cucumber).

Background: We have a yard worth testing. #
features/system_reports/inventory_check.feature:6
PGError: ERROR: column "id" does not exist
LINE 1: ...0000000', 'active, permanent, truck', 1, 't') RETURNING "id"

: INSERT INTO "valid_tag_ids" ("maximum", "is_reefer",
"is_permanent", "show_on_autocomplete", "minimum", "description",
"asset_type_id", "active") VALUES('0FFFFFFFFFFFFFFFFFFFFFFF', NULL,
't', 't', '000000000000000000000000', 'active, permanent, truck', 1,
't') RETURNING "id" (ActiveRecord::StatementInvalid)

It turns out that the valid_tag_id table has no id column, and no
primary key. Is there some way to create a factory for this bad boy?

--Eric

Joe Ferris

unread,
Oct 3, 2011, 9:52:05 AM10/3/11
to factor...@googlegroups.com
Hey Eric,

Can you take a look at this page and make sure that you can save those records without factory_girl? https://github.com/thoughtbot/factory_girl/wiki/How-factory_girl-interacts-with-ActiveRecord

factory_girl doesn't do anything special with IDs (it doesn't need them and relies on your ORM/database to generate them), so I think this is actually an issue with your model/ORM/database.

Thanks,
-Joe


--
Individuals over processes. Interactions over tools. Agile Rails training from thoughtbot, the makers of Clearance, Shoulda, & Factory Girl:
http://thoughtbot.com/services/training

You received this message because you are subscribed to the "factory_girl" mailing list.
To post to this group, send email to factor...@googlegroups.com
To unsubscribe from this group, send email to
factory_girl...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/factory_girl?hl=en

Reply all
Reply to author
Forward
0 new messages