Where should I store form field 'hints' data?
Many form fields (and form builders - simple_form, formtastic) use 'Hints' to explain more about the field. I will be using hints in the form and the show view (multiple places), so I want to store them somewhere external to the form or view.
Is there a rails built-in way to solve this issue? If not where is the recommended place to store these hints, and relate them to the table fields? I've considered in the model itself, or in config.ym开发者_C百科l.
Why don't you store those fields in the config/locales directory? This will help you internationalize your hints using the built-in rails I18n API. Those files are YML and you will have on file per language, like:
# en.yml
en:
forms:
hints:
username: Your username
#etc.
Then inside your views you will integrate those hints using: t('forms.hints.username')
etc.
精彩评论