Fix bug where polymorphic select is used on a non ActiveRecord object

If an association doesn't exist, generate the primary key manually