Adapt to Rails 7.2 Serialization

This commit is contained in:
Henne Vogelsang 2025-08-12 17:24:30 +02:00
parent 3a2df26b91
commit 7948a5356e
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
3 changed files with 16 additions and 6 deletions

View file

@ -4,7 +4,12 @@ class Conference < ApplicationRecord
include RevisionCount
require 'uri'
serialize :events_per_week, Hash
if RailsVersion.next?
serialize :events_per_week, type: Hash
else
serialize :events_per_week, Hash
end
# Needed to call 'Conference.with_role' in /models/ability.rb
# Dependent destroy will fail as roles#destroy will be cancelled,hence delete_all
resourcify :roles, dependent: :delete_all
@ -826,7 +831,12 @@ class Conference < ApplicationRecord
unless result[state.to_s.capitalize]
result[state.to_s.capitalize] = {}
end
result[state.to_s.capitalize][week.strftime('%W').to_i] = value
week_date_time = if RailsVersion.next?
DateTime.parse(week)
else
week
end
result[state.to_s.capitalize][week_date_time.strftime('%W').to_i] = value
end
end
end