lib/settings.rb in settings-goo-0.3.4 vs lib/settings.rb in settings-goo-0.3.5

- old
+ new

@@ -29,13 +29,16 @@ nil end end def self.[]=(key, val) - return nil if key.blank? - setting = Settings.find_key(key.to_s) - setting.update_attribute(:value, val) if setting + setting = Settings.find_key(key) + if setting + setting.update_attribute(:value, val) + else + nil + end end def self.keys Rails.cache.fetch("settings/settings.keys") { self.find(:all, :select => 'key', :order => 'key ASC').map{|setting| setting.key.to_sym} @@ -45,9 +48,10 @@ def self.remove(key) Settings.destroy_all(:key => key.to_s).first end private def self.find_key(key) + return nil if key.blank? key = key.to_s Settings.find_by_key(key) || Settings.new(:key => key) end def self.find_cached(key)