Don't raise error when an optional association can't be walked

This updates the stack record logic to not throw the custom no
record class error if the association isn't required. This was a
short sight in the previous implementation and caused minor
issues with optional polymorphic associations. Unless manually set,
an optional polymorphic association won't have its foreign type
column set. With the previous logic, it would fail everytime a
stack was built using it. This fixes the issue by only throwing
the exception if there isn't a record class and if the association
is required (going to be walked).