I'm working on a user model that needs to generate a key if the user's field is empty. If the user already has a key in the database, we wouldn't need to generate a new one. Where and what would be the best way to do this?

Examples:
---------

**One:**
*User without a key stored in the database:*   

Model should generate a new key and save it to the user.

**Two:**
*User with a key already in the database:*   

Model shouldn't change anything, except what the save was already going to modify.