Commit 74c15a6a2ce81f829833f59b92f87ca34961dfd2
1 parent
2dd932d8
Exists in
master
and in
1 other branch
Avoid error on badge migration
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
db/migrate/20151003000212_move_badge_threshold_to_action_key.rb
@@ -6,6 +6,7 @@ class MoveBadgeThresholdToActionKey < ActiveRecord::Migration | @@ -6,6 +6,7 @@ class MoveBadgeThresholdToActionKey < ActiveRecord::Migration | ||
6 | GamificationPlugin::Badge.all.each do |badge| | 6 | GamificationPlugin::Badge.all.each do |badge| |
7 | next if Merit::BadgeRules::AVAILABLE_RULES[badge.name.to_sym].nil? | 7 | next if Merit::BadgeRules::AVAILABLE_RULES[badge.name.to_sym].nil? |
8 | Merit::BadgeRules::AVAILABLE_RULES[badge.name.to_sym].each do |setting| | 8 | Merit::BadgeRules::AVAILABLE_RULES[badge.name.to_sym].each do |setting| |
9 | + badge.custom_fields = {} unless badge.custom_fields.is_a? Hash | ||
9 | badge.custom_fields[setting[:action]] = {threshold: badge.custom_fields[:threshold]} unless badge.custom_fields[:threshold].nil? | 10 | badge.custom_fields[setting[:action]] = {threshold: badge.custom_fields[:threshold]} unless badge.custom_fields[:threshold].nil? |
10 | badge.save | 11 | badge.save |
11 | end | 12 | end |