From b0de03cc0927083ab67c870a374e7e8463056084 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 27 May 2020 17:45:35 -0400 Subject: [PATCH] Fixed migration erroring (#1681) --- db/migrate/20200413150518_add_role_id_to_users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200413150518_add_role_id_to_users.rb b/db/migrate/20200413150518_add_role_id_to_users.rb index 18b0863c..45b018ce 100644 --- a/db/migrate/20200413150518_add_role_id_to_users.rb +++ b/db/migrate/20200413150518_add_role_id_to_users.rb @@ -16,7 +16,7 @@ class AddRoleIdToUsers < ActiveRecord::Migration[5.2] MigrationProduct.where(role_id: nil).each do |user| highest_role = SubMigrationProduct.joins("INNER JOIN users_roles ON users_roles.role_id = roles.id") - .where("users_roles.user_id = '#{user.id}'").min_by(&:priority).id + .where("users_roles.user_id = '#{user.id}'")&.min_by(&:priority)&.id user.update_attributes(role_id: highest_role) unless highest_role.nil? end end