创建新的运费计算器时遇到问题:
app/models/Spree/Calculator/Shipping/Andreani.rb:
class Andreani < Spree::Calculator::Shipping::Andreani
def Spree
andreani = 197
return 'andreani'
end
def compute_package(package)
return 'andreani'
end
end
配置/spree.rb
config = Rails.application.config
config.spree.calculators.shipping_methods << Spree::Calculator::Shipping::Andreani
输出:/home/darthganz/Desktop/datasoftok/config/initializers/spree.rb:34:in <main>': uninitialized constant Spree::Calculator::Shipping::Andreani (NameError) from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in
load' 来自 /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib /bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in load' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/engine.rb:681:in
block in load_config_initializer' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb :205:in instrument' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/engine.rb:680:in
load_config_initializer' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/engine.rb:634:in block (2 levels) in <class:Engine>' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in
each' from /home/darthganz/ .rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in block in <class:Engine>' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in
instance_exec' 来自 /home/darthganz/.rvm/gems/ruby-3.0.2/gems /railties-6.1.4.1/lib/rails/initializable.rb:32:inrun' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in
在 /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:228 中的 run_initializers 中的block in tsort_each' from /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:350:in
块:在 /home/darthganz/ 中的 each_strongly_connected_component 中的块(2 级)中.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:422:in block (2 levels) in each_strongly_connected_component_from' from /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:431:in
each_strongly_connected_component_from' 来自 /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0 .0/tsort.rb:421:in block in each_strongly_connected_component_from' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in
each' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in tsort_each_child' from /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:415:in
call'来自 /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:415:in each_strongly_connected_component_from' from /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:349:in
block in each_strongly_connected_component' 来自 /home/darthganz/.rvm/rubies/ruby-3.0 .2/lib/ruby/3.0.0/tsort.rb:347:in each' from /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:347:in
call' 来自 /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:347 :在each_strongly_connected_component' from /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:226:in
tsort_each' 来自 /home/darthganz/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:205:in tsort_each' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in
run_initializers' 来自 /home/darthganz/.rvm/gems/ruby-3.0 .2/gems/railties-6.1.4.1/lib/rails/application.rb:391:in initialize!' from /home/darthganz/Desktop/datasoftok/config/environment.rb:5:in
'来自 /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/ bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in
block in require_with_bootsnap_lfi' 来自 /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index。 rb:92:in register' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in
require_with_bootsnap_lfi' 来自 /home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:inrequire' from /home/darthganz/.rvm/gems/ruby-3.0.2/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in
需要'来自/home/darthganz/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'