Skip to content

Instantly share code, notes, and snippets.

@mscottford
Created January 10, 2012 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mscottford/1589460 to your computer and use it in GitHub Desktop.
Save mscottford/1589460 to your computer and use it in GitHub Desktop.
spree calculator issue
module Mcsweeneys
class Application < Rails::Application
# snip
config.to_prepare do
## snip
Spree::Environment::Calculators.class_eval do
attr_accessor :handling_fees
end
end
# snip
initializer "spree.register.calculators" do |app|
app.config.spree.calculators.add_class('handling_fees')
app.config.spree.calculators.handling_fees = [
Calculator::McsweeneysHandlingCharge
]
end
end
end
:rvm => 'ruby-1.9.2@mcsweeneys'
cloudraker:mcsweeneys mscottford$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:152:in `block in tsort_each': topological sort failed: [** SNIPPED A TON OF UGLINESS **] (TSort::Cyclic)
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:180:in `each'
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
from /Users/mscottford/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/tsort.rb:135:in `tsort'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/mscottford/src/railsdog/mcsweeneys/config/environment.rb:5:in `<top (required)>'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /Users/mscottford/src/railsdog/mcsweeneys/config.ru:4:in `block in <main>'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/builder.rb:51:in `initialize'
from /Users/mscottford/src/railsdog/mcsweeneys/config.ru:1:in `new'
from /Users/mscottford/src/railsdog/mcsweeneys/config.ru:1:in `<main>'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/builder.rb:40:in `eval'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/server.rb:200:in `app'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/commands/server.rb:46:in `app'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/server.rb:301:in `wrapped_app'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/rack-1.3.5/lib/rack/server.rb:252:in `start'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in `start'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/commands.rb:54:in `block in <top (required)>'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap'
from /Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/railties-3.1.1/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
@benjamintanweihao
Copy link

I think it's abit late, but I stumbled onto a similar situation. It seems like the order which Spree's initializer blocks matters.

@exomarc
Copy link

exomarc commented Oct 16, 2012

Holy cow, this saved my life. Thanks for posting the solution to the problem I was having.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment