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

@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-08-12 13:33:30 UTC using RuboCop version 1.79.2.
# on 2025-08-12 15:04:30 UTC using RuboCop version 1.79.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@ -545,7 +545,7 @@ Metrics/BlockNesting:
# Offense count: 14
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 646
Max: 655
# Offense count: 24
# Configuration parameters: AllowedMethods, AllowedPatterns.
@ -2074,7 +2074,7 @@ Style/WordArray:
EnforcedStyle: percent
MinSize: 6
# Offense count: 431
# Offense count: 430
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https

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

View file

@ -36,6 +36,6 @@ module Osem
# This is a nightmare with our current data model, no one ever thought about this.
config.active_record.belongs_to_required_by_default = false
# https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
config.active_record.yaml_column_permitted_classes = ['Date', 'DateTime', 'Symbol', 'Time', 'ActiveSupport::TimeWithZone', 'ActiveSupport::TimeZone']
config.active_record.yaml_column_permitted_classes = [Date, DateTime, Symbol, Time, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone]
end
end