vendredi 6 mars 2015

displaying/accepting one value in number form field (e.g. age) but storing another (e.g. year of birth)

I could do the conversions in the edit/update/create controller actions, but is there a more elegant way to do this? When using a collection, it's pretty easy to do with with value_method/display_method. But when I try to do it with just a simple integer input field, value_method/display_method don't seem work, or maybe I'm doing the syntax wrong. I'm also having a surprisingly hard time finding anything about this on google.


Ideally the solution would work both for new and edit, so the user always sees/enters an age value in the form but it's always stored as yob.


Aucun commentaire:

Enregistrer un commentaire