Class: Spree::PreferenceRescue

Inherits:
Object
  • Object
show all
Defined in:
lib/spree/core/preference_rescue.rb

Class Method Summary collapse

Class Method Details

.tryObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/spree/core/preference_rescue.rb', line 9

def self.try
  OldPrefs.where(:key => nil).each do |old_pref|
    next unless owner = (old_pref.owner rescue nil)
    unless old_pref.owner_type == "Spree::Activator" || old_pref.owner_type == "Spree::Configuration"
      old_pref.key = [owner.class.name, old_pref.name, owner.id].join('::').underscore
      old_pref.value_type = owner.preference_type(old_pref.name)
      puts "Migrating Preference: #{old_pref.key}"
      old_pref.save
    end
  end
end