DEV Community

Discussion on: Rails Minitest Has Many And Belongs To Model Test ActiveRecord::UnknownPrimaryKey Error

Collapse
 
rhymes profile image
rhymes

I don't think this has much to do with minitest, it has more to do with Rails fixtures.

You need explicit IDs if you want HABTM relations to work with those: api.rubyonrails.org/classes/Active...

Hope I understood correctly and that this helps!

Collapse
 
captainawesomedi profile image
Di Wu

I figured it out myself, I dont need fixture to do it.

Collapse
 
rhymes profile image
rhymes

Good!

You might want to share the solution, for future readers :)

Thread Thread
 
captainawesomedi profile image
Di Wu

I have posted on stackoverflow haha