Is it possible to set a display name for a database field, instead of using the auto-generated one?
I've got a field bbe_date
, and in screens, I am using 'Best Before' as the displayed string. I have been through a few views setting this manually, but is there a better way?
This would hopefully take effect wherever the field name is sent to the browser in human-readable form. I'm particularly thinking about validation errors as well (since that's the bit I haven't already handled manually!) - my validation code is doing:
record.errors.add :bbe_date, 'not valid'
but unless I specially intercept this, I just see 'Bbe date not valid' as the validation error.
You need internationalization (I18N). Yup, even if you just want English.
Modify config/locales/en.yml, and set:
en:
activerecord:
attributes:
your_lower_case_model_name:
bbe_date: Best Before
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With