Make sure the instance is persisted before trying to get it's id
Merge pull request #838 from chancedowns/check-persisted

Make sure the instance is persisted before trying to get it's id