Fixes restoring polymorphic has_one relationships

If the association object is a has_one relationship with an :as option,
it will have a type attribute (see
https://github.com/rails/docrails/blob/master/activerecord/lib/active_record/reflection.rb#L280).

If this type attributes is present, that will be the type column on the
polymorphic model. The foreign key can be found as an attribute on
the association object.