README.md in rails-settings-cached-0.3.2 vs README.md in rails-settings-cached-0.4.0

- old
+ new

@@ -15,10 +15,12 @@ ## Setup Edit your Gemfile: ```ruby +# Rails 4.1.x +gem "rails-settings-cached", "0.4.0" # Rails 4+ gem "rails-settings-cached", "0.3.1" # Rails 3.x gem "rails-settings-cached", "0.2.4" ``` @@ -82,21 +84,21 @@ ``` Want a list of all the settings? ```ruby -Setting.all +Setting.get_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.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 like this: ```ruby Setting['preferences.color'] = :blue Setting['preferences.size'] = :large Setting['license.key'] = 'ABC-DEF' -Setting.all('preferences.') +Setting.get_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` @@ -133,11 +135,11 @@ ```ruby user = User.find(123) user.settings.color = :red user.settings.color # returns :red -user.settings.all # { "color" => :red } +user.settings.get_all # { "color" => :red } ``` I you want to find users having or not having some settings, there are named scopes for this: ```ruby @@ -146,12 +148,32 @@ User.with_settings_for('color') # => returns a scope of users having a 'color' setting User.without_settings -# returns a scope of users having no setting at all (means user.settings.all == {}) +# returns a scope of users having no setting at all (means user.settings.get_all == {}) User.without_settings('color') # returns a scope of users having no 'color' setting (means user.settings.color == nil) ``` + +----- + +## How to create a list, form to manage Settings? + +If you want create an admin interface to editing the Settings, you can try methods in follow: + +```ruby +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!