huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

Boolean setting having false value returns nil #89

Closed rvsingh closed 8 years ago

rvsingh commented 8 years ago

A boolean setting when set as false gets commited.

 pry(main)> Setting.FLAG  = false
 => false

But when again fetched in it returns nil.

 pry(main)> Settings.FLAG
 => nil
huacnlee commented 8 years ago

Tell me your rails-settings-cached version, and Rails version

huacnlee commented 8 years ago
2.3.0 :001 > SiteConfig.foo = false
  SiteConfig Load (18.6ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = $1 ORDER BY "settings"."id" ASC LIMIT $2  [["var", "foo"], ["LIMIT", 1]]
   (6.3ms)  BEGIN
  SQL (17.2ms)  UPDATE "settings" SET "value" = $1, "updated_at" = $2 WHERE "settings"."id" = $3  [["value", "--- false\n...\n"], ["updated_at", 2016-03-04 15:11:51 UTC], ["id", 16]]
   (1.6ms)  COMMIT
  CACHE: write rails_settings_cached:foo
Dalli::Server#connect 127.0.0.1:11211
 => false 
2.3.0 :002 > SiteConfig.foo
  CACHE: read rails_settings_cached:foo
 => false 

Rails 5.0, rails-settings-cached newest version.

dangerous commented 8 years ago

The bug does exist but not when retrieving from the cache.

I have submitted a PR that fixes the bug: https://github.com/huacnlee/rails-settings-cached/pull/97