Simplified, permanent key-value store for global application settings.
Add following to Gemfile
:
gem 'ar-settings', require: 'settings'
then bundle install
Run generator to add migration:
$ rails generate install_settings
Gem implements minimal amount of public methods needed to manage settings
Settings.set(:key, 'value') # store a value
Settings.get(:key) # fetch a value
Settings.key = 'value' # equivalent to Settings.set(...)
Settings.key # equivalent to Settings.get(...)
Method convenient for handling settings form submission.
Settings.update({
key: 'value',
key2: 'value2',
...
})
Settings.has(:key) # check if setting field exists
Settings.unset(:key) # remove stored value if exists
- Utilize
Rails.cache
to reduce overhead of querying db
Licensed under the MIT license.