Is there any documentation, or advice?
You can use Active Model
Take a look here.
Look at the source code at Github.