huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

I need a description for my "key > value" pair. Now I explain better... #104

Closed ghost closed 5 years ago

ghost commented 8 years ago

I'm using the basic form in Readme, but I receive my "var" content, eg. "telephoneNumber", instead I need a description in my form, something like: "Telephone number of boss". In the database schema I need a new column for this? Something like a "description" column? Or I'm totally wrong?

If I change my var in: "Telephone number of boss" I need to recall in my code what? This: Setting.Telephone number of boss?????? IMPOSSIBLE! No?

brentkearney commented 7 years ago

One way would be to use a hash value: Setting.phone = { telephoneNumber: '111-222-3333', description: 'Telephone number of boss' }

Then in your form, you could have:

<label><%= Setting.phone['description'] %></label>
<p><%= f.phone_number, value: Setting.phone['telephoneNumber'] %></p>
huacnlee commented 5 years ago

Use Rails I18n https://guides.rubyonrails.org/i18n.html