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 don't want to hard code into your rails app. You can store any kind of object. Strings, numbers, arrays, or any serializable object.
MIT License
212
stars
16
forks
source link
defaults in settings.rb where value is false cannot be retrieved (nil is given instead) #4
If I specify a setting default which is false, for example
Settings.defaults[:debug] = false
in my Settings.defaults i see it:
ruby-1.9.2-p290 :007 > Settings.defaults
=> {"bla"=>"blubb", "blubb"=>true, "ble"=>13, "cocktails"=>["Martini", "Black", "White Russian"], "debug"=>false}
but Settings.debug gives me back nil instead of false.
ruby-1.9.2-p290 :008 > Settings.debug
Settings Load (0.6ms) SELECT settings.* FROM settings WHERE settings.var = 'debug' LIMIT 1
=> nil
If i specify a default with the value true everything works fine.
tried in rails 3.0.1
If I specify a setting default which is false, for example
Settings.defaults[:debug] = false
in my Settings.defaults i see it: ruby-1.9.2-p290 :007 > Settings.defaults => {"bla"=>"blubb", "blubb"=>true, "ble"=>13, "cocktails"=>["Martini", "Black", "White Russian"], "debug"=>false}
but Settings.debug gives me back nil instead of false. ruby-1.9.2-p290 :008 > Settings.debug
Settings Load (0.6ms) SELECT
settings
.* FROMsettings
WHEREsettings
.var
= 'debug' LIMIT 1 => nilIf i specify a default with the value true everything works fine.
ruby-1.9.2-p290 :009 > Settings.defaults[:debug] = true => true ruby-1.9.2-p290 :010 > Settings.debug Settings Load (0.5ms) SELECT
settings
.* FROMsettings
WHEREsettings
.var
= 'debug' LIMIT 1 => true