Avoid crash when adding new translations

Paranoia is activated on translation classes by reflection, this is
making Rails to load translation classes before to execute migration
that adds the new column.

With this extra check Rails will not execute this code until translation
table has this column created.
This commit is contained in:
Senén Rodero Rodríguez
2019-02-13 17:51:19 +01:00
committed by voodoorai2000
parent 90df1faf07
commit b86579c40f

View File

@@ -17,7 +17,7 @@ module Globalizable
self.read_attribute(:description).try :html_safe self.read_attribute(:description).try :html_safe
end end
if self.paranoid? if self.paranoid? && translation_class.attribute_names.include?("hidden_at")
translation_class.send :acts_as_paranoid, column: :hidden_at translation_class.send :acts_as_paranoid, column: :hidden_at
end end
end end