From 341fce956eb536a994d59e968d5d5ef8386eb504 Mon Sep 17 00:00:00 2001 From: hoverlover Date: Sat, 1 Sep 2012 00:16:36 -0500 Subject: [PATCH] Fix for getting around mass assignment whitelist. --- lib/preferences.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/preferences.rb b/lib/preferences.rb index 23ae075..b107c04 100644 --- a/lib/preferences.rb +++ b/lib/preferences.rb @@ -585,7 +585,12 @@ def update_preferences preferences.keys.each do |name| # Find an existing preference or build a new one attributes = {:name => name, :group_id => group_id, :group_type => group_type} - preference = find_preferences(attributes).first || stored_preferences.build(attributes) + + unless (preference = find_preferences(attributes).first) + preference = stored_preferences.build + attributes.each_pair { |attribute, value| preference[attribute] = value } + end + preference.value = preferred(name, group) preference.save! end