Use base_class when checking valid class type

The dynamically generated setter allowed assigning a specified class or its
direct descendant, but it did not allow for arbitrary depth descendants. By
using base_class we will always get the first ActiveRecord class.
Use InvalidTypeError when type is invalid

It was using the generic PolymorphicError which doesn't have a helpful message.