flyerhzm / bullet

help to kill N+1 queries and unused eager loading
MIT License
7.06k stars 431 forks source link

ActiveRecord unknown primary key due to Bullet #338

Open alxndrdude opened 7 years ago

alxndrdude commented 7 years ago

Creation of new Record with before_validation hook fails if Bullet.enable = true

I have a rails ActiveRecord model, say AR1, with a before_validation hook. This hooks calls a function to create another ActiveRecord, say AR2, before AR1 is created.

In case Bullet is active, AR2 seems to get modified, such that a creation of AR1, which triggers first a creation of AR2, leads to:

The database and models are configured correctly. Without Bullet.enable = true everything works. Unit and feature test run green, since gem bullet is grouped under development.

Any advice?

thanks!

see error logs (AR1 -> EnergyManagementSystem, AR2 -> TechnicianGroup): stacktrace.txt

angelfan commented 7 years ago

@alxndrdude 你是否使用了 composite_primary_keys