Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mladenilic/ar-settings
Global application settings for Ruby on Rails built on Active Record
https://github.com/mladenilic/ar-settings
activerecord configuration ruby-gem ruby-on-rails settings-storage
Last synced: about 2 months ago
JSON representation
Global application settings for Ruby on Rails built on Active Record
- Host: GitHub
- URL: https://github.com/mladenilic/ar-settings
- Owner: mladenilic
- Created: 2019-03-19T18:13:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-21T17:33:23.000Z (almost 6 years ago)
- Last Synced: 2024-12-15T13:19:00.437Z (about 2 months ago)
- Topics: activerecord, configuration, ruby-gem, ruby-on-rails, settings-storage
- Language: Ruby
- Homepage: https://drei.one/
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Application Settings for Ruby on Rails built on Active Record
[![Gem Version](https://badge.fury.io/rb/ar-settings.svg)](https://badge.fury.io/rb/ar-settings) [![Build Status](https://travis-ci.org/mladenilic/ar-settings.svg?branch=master)](https://travis-ci.org/mladenilic/ar-settings) [![Maintainability](https://api.codeclimate.com/v1/badges/c32df8f8675774adf2d1/maintainability)](https://codeclimate.com/github/mladenilic/ar-settings/maintainability)
Simplified, permanent key-value store for global application settings.
## Getting Started
Add following to `Gemfile`:
```rb
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
```rb
Settings.set(:key, 'value') # store a value
Settings.get(:key) # fetch a value
``````rb
Settings.key = 'value' # equivalent to Settings.set(...)
Settings.key # equivalent to Settings.get(...)
```### Mass update
Method convenient for handling settings form submission.
```rb
Settings.update({
key: 'value',
key2: 'value2',
...
})
```### Additional methods
```rb
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.