README.md in rails-settings-cached-0.4.1 vs README.md in rails-settings-cached-0.4.2

- old
+ new

@@ -1,13 +1,13 @@ # Settings Gem -This is improved from rails-settings, added caching for all settings. -Settings is a plugin that makes managing a table of global key, value pairs easy. -Think of it like a global Hash stored in you database, that uses simple ActiveRecord -like methods for manipulation. Keep track of any global setting that you dont want -to hard code into your rails app. You can store any kind of object. Strings, numbers, -arrays, or any object. Ported to Rails 3! +This is improved from [rails-settings](https://github.com/ledermann/rails-settings), +added caching for all settings. Settings is a plugin that makes managing a table of +global key, value pairs easy. Think of it like a global Hash stored in your database, +that uses simple ActiveRecord like methods for manipulation. Keep track of any global +setting that you dont want to hard code into your rails app. You can store any kind +of object. Strings, numbers, arrays, or any object. ## Status - [![Gem Version](https://badge.fury.io/rb/rails-settings-cached.png)](https://rubygems.org/gems/rails-settings-cached) - [![CI Status](https://api.travis-ci.org/huacnlee/rails-settings-cached.png)](http://travis-ci.org/huacnlee/rails-settings-cached) @@ -82,23 +82,28 @@ Setting.destroy :foo Setting.foo # returns nil ``` Want a list of all the settings? - ```ruby +# Rails 4.1.x Setting.get_all +# Rails 3.x and 4.0.x +Setting.all # returns {'admin_password' => 'super_secret', 'date_format' => '%m %d, %Y'} ``` -You need name spaces and want a list of settings for a give name space? Just choose your prefered named space delimiter and use Setting.get_all like this: +You need name spaces and want a list of settings for a give name space? Just choose your prefered named space delimiter and use `Setting.get_all` (`Settings.all` for # Rails 3.x and 4.0.x) like this: ```ruby Setting['preferences.color'] = :blue Setting['preferences.size'] = :large Setting['license.key'] = 'ABC-DEF' +# Rails 4.1.x Setting.get_all('preferences.') +# Rails 3.x and 4.0.x +Setting.all('preferences.') # returns { 'preferences.color' => :blue, 'preferences.size' => :large } ``` Set defaults for certain settings of your app. This will cause the defined settings to return with the Specified value even if they are **not in the database**. Make a new file in `config/initializers/default_settings.rb` @@ -135,11 +140,15 @@ ```ruby user = User.find(123) user.settings.color = :red user.settings.color # returns :red -user.settings.get_all # { "color" => :red } +# Rails 4.1.x +user.settings.get_all +# Rails 3.x and 4.0.x +user.settings.all +# { "color" => :red } ``` I you want to find users having or not having some settings, there are named scopes for this: ```ruby @@ -166,14 +175,16 @@ class SettingsController < ApplicationController def index # to get all items for render list @settings = Setting.unscoped end - + def edit @setting = Setting.unscoped.find(params[:id]) end end ``` -That's all there is to it! Enjoy! +Also you may use [rails-settings-ui](https://github.com/accessd/rails-settings-ui) gem +for building ready to using interface with validations. +