I have a table in postgres with date_of_birth and would like to use the Postgres age function to return the age, rather than calculate the age in Rails (this is a simple example, I will want to do more complicated calculations in postgres).
What is the best way to get the age back from postgres with the rest of my record, ideally as standard without having to modify every select?
EDIT:
I've decided to use views because:
- My database will be used by other applications other than rails and I want to define common functions that all of them can use.
- I'd like to control access to the data over multiple applications.
- It takes some of the processing away from the application server.
- It is more scalable if I use a lot of calculated fields.