Created
December 15, 2013 20:07
-
-
Save FineLineAutomation/7977480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== MigrateOldShippingCalculators: migrating ================================== | |
rake aborted! | |
An error has occurred, this and all later migrations canceled: | |
The single-table inheritance mechanism failed to locate the subclass: 'Spree::Calculator::Ups::ThreeDaySelect'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Spree::Calculator.inheritance_column to use another column for that information./Users/nate/Projects/Websites/spree-fine-line-automation/db/migrate/20131215195190_migrate_old_shipping_calculators.spree.rb:5:in `block in up' | |
/Users/nate/Projects/Websites/spree-fine-line-automation/db/migrate/20131215195190_migrate_old_shipping_calculators.spree.rb:4:in `each' | |
/Users/nate/Projects/Websites/spree-fine-line-automation/db/migrate/20131215195190_migrate_old_shipping_calculators.spree.rb:4:in `up' | |
/Users/nate/.rvm/gems/ruby-1.9.3-p286@global/bin/ruby_noexec_wrapper:14:in `eval' | |
/Users/nate/.rvm/gems/ruby-1.9.3-p286@global/bin/ruby_noexec_wrapper:14:in `<main>' | |
Tasks: TOP => db:migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This migration comes from spree (originally 20130830001159) | |
class MigrateOldShippingCalculators < ActiveRecord::Migration | |
def up | |
Spree::ShippingMethod.all.each do |shipping_method| | |
old_calculator = shipping_method.calculator | |
next if old_calculator.class < Spree::ShippingCalculator # We don't want to mess with new shipping calculators | |
new_calculator = eval("Spree::Calculator::Shipping::#{old_calculator.class.name.demodulize}").new | |
new_calculator.preferences.keys.each do |pref| | |
# Preferences can't be read/set by name, you have to prefix preferred_ | |
pref_method = "preferred_#{pref}" | |
new_calculator.send("#{pref_method}=", old_calculator.send(pref_method)) | |
end | |
new_calculator.calculable = old_calculator.calculable | |
new_calculator.save | |
end | |
end | |
def down | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment