Sha256: e680726eed4271c7f22f874f7e0a03c2967fbb782d931c732a23220ba02d340f
Contents?: true
Size: 712 Bytes
Versions: 10
Compression:
Stored size: 712 Bytes
Contents
module Spree class OldPrefs < ActiveRecord::Base self.table_name = "spree_preferences" belongs_to :owner, :polymorphic => true attr_accessor :owner_klass end class PreferenceRescue 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 end end
Version data entries
10 entries across 10 versions & 1 rubygems