fix: undefined method `foreign_key' for nil:NilClass