From dc88212b75dfeac285fa926ed181934f288a160b Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Mon, 25 Mar 2019 18:14:13 +0100 Subject: [PATCH] Remove Budget::Phase overrided translation class Since Globalize gem update to v5.2.0 we cannot override translations anymore in the same way that before the update. Milestone::Translation class removed in this commit were no longer loaded correctly when translation class is retrieved by translation_class method provided by Globalize. Here is the diff between both gem versions: https://github.com/globalize/globalize/compare/v5.0.0...v5.2.0diff-a1370b109e0dd567545b072bc6447b8fR51 This problem is not happening on test environment but is throwing an exception in other environments as it has not loaded the delegation definition inside our custom translation class. To fix this we added a new class method inside globalizable model concern to allow to define method delegation on translations classes from parent globalizable classes when needed without having to override Translation classes. Since module Sanitizable takes care of traslations, it's enough to include the module in order to correctly sanitize the description. --- app/models/budget/phase.rb | 1 + app/models/budget/phase/translation.rb | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 app/models/budget/phase/translation.rb diff --git a/app/models/budget/phase.rb b/app/models/budget/phase.rb index cd877e0cc..2c50c10e8 100644 --- a/app/models/budget/phase.rb +++ b/app/models/budget/phase.rb @@ -9,6 +9,7 @@ class Budget translates :summary, touch: true translates :description, touch: true include Globalizable + include Sanitizable belongs_to :budget belongs_to :next_phase, class_name: "Budget::Phase", foreign_key: :next_phase_id diff --git a/app/models/budget/phase/translation.rb b/app/models/budget/phase/translation.rb deleted file mode 100644 index 53390143a..000000000 --- a/app/models/budget/phase/translation.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Budget::Phase::Translation < Globalize::ActiveRecord::Translation - before_validation :sanitize_description - - private - - def sanitize_description - self.description = WYSIWYGSanitizer.new.sanitize(description) - end -end