[#467] Fix uninitialized constant Journal::Journaled error
Was due to Journals touching the parent record but the Journal not having it's STI class correct during the type update.
This commit is contained in:
parent
0c03142832
commit
b52d2b2238
@ -35,10 +35,14 @@ class GeneralizeJournals < ActiveRecord::Migration
|
||||
|
||||
Journal.all.group_by(&:journaled_id).each_pair do |id, journals|
|
||||
journals.sort_by(&:created_at).each_with_index do |j, idx|
|
||||
j.update_attribute(:type, "#{j.journalized_type}Journal")
|
||||
j.update_attribute(:version, idx + 1)
|
||||
# Recast the basic Journal into it's STI journalized class so callbacks work (#467)
|
||||
klass_name = "#{j.journalized_type}Journal"
|
||||
j = j.becomes(klass_name.constantize)
|
||||
j.type = klass_name
|
||||
j.version = idx + 1
|
||||
# FIXME: Find some way to choose the right activity here
|
||||
j.update_attribute(:activity_type, j.journalized_type.constantize.activity_provider_options.keys.first)
|
||||
j.activity_type = j.journalized_type.constantize.activity_provider_options.keys.first
|
||||
j.save(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user