Skip to content

Global application settings for Ruby on Rails built on Active Record

Notifications You must be signed in to change notification settings

mladenilic/ar-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Application Settings for Ruby on Rails built on Active Record

Gem Version Build Status Maintainability

Simplified, permanent key-value store for global application settings.

Getting Started

Add following to Gemfile:

gem 'ar-settings', require: 'settings'

then bundle install

Run generator to add migration:

$ rails generate install_settings

Usage

Gem implements minimal amount of public methods needed to manage settings

Storing and fetching 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(...)

Mass update

Method convenient for handling settings form submission.

Settings.update({
  key: 'value',
  key2: 'value2',
  ...
})

Additional methods

Settings.has(:key)             # check if setting field exists
Settings.unset(:key)           # remove stored value if exists

To do

  1. Utilize Rails.cache to reduce overhead of querying db

Licence

Licensed under the MIT license.

About

Global application settings for Ruby on Rails built on Active Record

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published