1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Fixed mat assignment rules to be db agnostic with comma delimited strings and upgraded test env db to mariadb 10.10 to match production.

This commit is contained in:
2025-01-25 20:02:22 -05:00
parent 54655a2ea9
commit 690e497654
8 changed files with 76 additions and 60 deletions

View File

@@ -2,11 +2,28 @@ class MatAssignmentRule < ApplicationRecord
belongs_to :mat
belongs_to :tournament
# Ensure default values for JSON fields
# because mysql doesn't allow this
after_initialize do
self.weight_classes ||= []
self.bracket_positions ||= []
self.rounds ||= []
# Convert comma-separated values to arrays
def weight_classes
(super || "").split(",").map(&:to_i)
end
def weight_classes=(value)
super(value.is_a?(Array) ? value.join(",") : value)
end
def bracket_positions
(super || "").split(",")
end
def bracket_positions=(value)
super(value.is_a?(Array) ? value.join(",") : value)
end
def rounds
(super || "").split(",").map(&:to_i)
end
def rounds=(value)
super(value.is_a?(Array) ? value.join(",") : value)
end
end