Commit 308261afd069044dd7cf4345532e937746f8ec4d

Authored by Victor Costa
1 parent ce907252
Exists in master

Fix update_all syntax in migration

db/migrate/20150930132305_move_points_category_to_categorization_tables.rb
@@ -7,13 +7,13 @@ class MovePointsCategoryToCategorizationTables < ActiveRecord::Migration @@ -7,13 +7,13 @@ class MovePointsCategoryToCategorizationTables < ActiveRecord::Migration
7 settings = Noosfero::Plugin::Settings.new(env, GamificationPlugin) 7 settings = Noosfero::Plugin::Settings.new(env, GamificationPlugin)
8 weight = settings.settings.fetch(:point_rules, {}).fetch(name.to_s, {}).fetch('weight', setting[:default_weight]).to_i 8 weight = settings.settings.fetch(:point_rules, {}).fetch(name.to_s, {}).fetch('weight', setting[:default_weight]).to_i
9 cat = GamificationPlugin::PointsCategorization.create(point_type_id: type.id, weight: weight) 9 cat = GamificationPlugin::PointsCategorization.create(point_type_id: type.id, weight: weight)
10 - Merit::Score.update_all "category = '#{cat.id}'", category: name 10 + Merit::Score.where(category: name).update_all(category: cat.id.to_s)
11 end 11 end
12 end 12 end
13 13
14 def down 14 def down
15 GamificationPlugin::PointsCategorization.all.each do |categorization| 15 GamificationPlugin::PointsCategorization.all.each do |categorization|
16 - Merit::Score.update_all "category = '#{categorization.point_type.name}'", category: categorization.id.to_s 16 + Merit::Score.where(category: categorization.id.to_s).update_all(category: categorization.point_type.name)
17 categorization.point_type.destroy 17 categorization.point_type.destroy
18 categorization.destroy 18 categorization.destroy
19 end 19 end