Fixing association foreign key issue and cached objects