[BUGFIX beta] Do not attempt to serialize undefined models.

If a routes model is undefined do not attempt to serialize it.

Previously, this would cause an error like: `Cannot call get with 'id'
on an undefined object.`.
Merge pull request #3933 from rjackson/fix_serialize_on_missing_models

[BUGFIX beta] Do not attempt to serialize undefined models.