summaryrefslogtreecommitdiffstats
path: root/app/models/user_preference.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user_preference.rb')
-rw-r--r--app/models/user_preference.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index d9601d516..1ed9e0fd9 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -26,11 +26,15 @@ class UserPreference < ActiveRecord::Base
self.others ||= {}
end
+ def before_save
+ self.others ||= {}
+ end
+
def [](attr_name)
if attribute_present? attr_name
super
else
- others[attr_name]
+ others ? others[attr_name] : nil
end
end
@@ -38,7 +42,8 @@ class UserPreference < ActiveRecord::Base
if attribute_present? attr_name
super
else
- others.store attr_name, value
+ self.others ||= {}
+ self.others.store attr_name, value
end
end
end