将产品添加到购物车时发生错误:
TypeError at /orders/populate
nil can't be coerced into Float
来自spree-fd575479ca20 / core / app / models / spree / item_adjustments.rb:
item.update_columns(
:promo_total => promo_total,
:included_tax_total => included_tax_total,
:additional_tax_total => additional_tax_total,
:adjustment_total => promo_total + additional_tax_total,
:updated_at => Time.now,
)
我已将问题追溯到item_adjustments.rb
中的这两行代码:
included_tax_total = tax.is_included.reload.map(&:update!).compact.sum
additional_tax_total = tax.additional.reload.map(&:update!).compact.sum
我可以通过将两者都设置为0来解决问题,但我确定我想要执行此操作:
included_tax_total = 0
additional_tax_total = 0
宝石版本:
gem 'spree', git: 'git@github.com:spree/spree', branch: '2-4-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-4-stable'
实例变量@item
#<Spree::LineItem id: nil, variant_id: 1, order_id: 4, quantity: 1, price: #<BigDecimal:c159b70,'0.1599E2',18(27)>, created_at: "2015-02-06 18:45:26", updated_at: "2015-02-06 18:45:26", currency: "USD", cost_price: #<BigDecimal:8d3d030,'0.17E2',9(18)>, tax_category_id: 1, adjustment_total: #<BigDecimal:c0035a0,'0.0',9(18)>, additional_tax_total: #<BigDecimal:c003578,'0.0',9(18)>, promo_total: #<BigDecimal:c003550,'0.0',9(18)>, included_tax_total: #<BigDecimal:c003528,'0.0',9(18)>, pre_tax_amount: #<BigDecimal:c003500,'0.0',9(18)>>
更长的错误:
Started POST "/store/orders/populate" for 127.0.0.1 at 2015-02-05 22:16:49 -0600
Processing by Spree::OrdersController#populate as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"tnscLkBcDAlPkPEq5xMZJDmSf90j+Sb3IXvIlmSOk64=", "variant_id"=>"1", "quantity"=>"1", "button"=>""}
Spree::Preference Load (0.2ms) SELECT `spree_preferences`.* FROM `spree_preferences` WHERE `spree_preferences`.`key` = 'spree/frontend_configuration/locale' LIMIT 1
Spree::Order Load (0.4ms) SELECT `spree_orders`.* FROM `spree_orders` WHERE `spree_orders`.`number` IS NULL LIMIT 1
Spree::Store Load (0.2ms) SELECT `spree_stores`.* FROM `spree_stores` WHERE (url like '%localhost%') ORDER BY `spree_stores`.`id` ASC LIMIT 1
Spree::Store Load (0.2ms) SELECT `spree_stores`.* FROM `spree_stores` WHERE `spree_stores`.`default` = 1 ORDER BY `spree_stores`.`id` ASC LIMIT 1
Spree::Order Load (0.2ms) SELECT `spree_orders`.* FROM `spree_orders` WHERE `spree_orders`.`completed_at` IS NULL AND `spree_orders`.`currency` = 'USD' AND `spree_orders`.`guest_token` = 'LO_p_oGy-8D5dy-J84tizA' AND `spree_orders`.`store_id` = 1 AND `spree_orders`.`user_id` IS NULL LIMIT 1
CACHE (0.0ms) SELECT `spree_orders`.* FROM `spree_orders` WHERE `spree_orders`.`completed_at` IS NULL AND `spree_orders`.`currency` = 'USD' AND `spree_orders`.`guest_token` = 'LO_p_oGy-8D5dy-J84tizA' AND `spree_orders`.`store_id` = 1 AND `spree_orders`.`user_id` IS NULL LIMIT 1
(0.2ms) BEGIN
Spree::Order Exists (0.3ms) SELECT 1 AS one FROM `spree_orders` WHERE `spree_orders`.`number` = 'R794021167' LIMIT 1
(0.3ms) SELECT COUNT(*) FROM `spree_orders` WHERE (spree_orders.number LIKE 'R794021167%')
Spree::Order Exists (0.7ms) SELECT 1 AS one FROM `spree_orders` WHERE `spree_orders`.`number` = BINARY 'R794021167' LIMIT 1
SQL (0.4ms) INSERT INTO `spree_orders` (`created_at`, `currency`, `guest_token`, `number`, `state`, `store_id`, `updated_at`) VALUES ('2015-02-06 04:16:49', 'USD', 'LO_p_oGy-8D5dy-J84tizA', 'R794021167', 'cart', 1, '2015-02-06 04:16:49')
(2.9ms) COMMIT
DEPRECATION WARNING: OrderPopulator is deprecated and will be removed from Spree 3, use OrderContents with order.contents.add instead. (called from populate at /home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/frontend/app/controllers/spree/orders_controller.rb:45)
Spree::Variant Load (0.3ms) SELECT `spree_variants`.* FROM `spree_variants` WHERE `spree_variants`.`deleted_at` IS NULL AND `spree_variants`.`id` = 1 LIMIT 1
Spree::LineItem Load (0.5ms) SELECT `spree_line_items`.* FROM `spree_line_items` WHERE `spree_line_items`.`order_id` = 4 ORDER BY spree_line_items.created_at ASC
Unpermitted parameters: currency
Spree::Price Load (0.2ms) SELECT `spree_prices`.* FROM `spree_prices` WHERE `spree_prices`.`deleted_at` IS NULL AND `spree_prices`.`variant_id` = 1
(0.2ms) BEGIN
Spree::Product Load (0.2ms) SELECT `spree_products`.* FROM `spree_products` WHERE `spree_products`.`id` = 1 LIMIT 1
Spree::TaxCategory Load (0.2ms) SELECT `spree_tax_categories`.* FROM `spree_tax_categories` WHERE `spree_tax_categories`.`deleted_at` IS NULL AND `spree_tax_categories`.`id` = 1 LIMIT 1
(0.2ms) SELECT SUM(`spree_stock_items`.`count_on_hand`) AS sum_id FROM `spree_stock_items` INNER JOIN `spree_stock_locations` ON `spree_stock_locations`.`id` = `spree_stock_items`.`stock_location_id` WHERE `spree_stock_items`.`deleted_at` IS NULL AND `spree_stock_items`.`variant_id` = 1 AND `spree_stock_locations`.`active` = 1
SQL (0.5ms) INSERT INTO `spree_line_items` (`cost_price`, `created_at`, `currency`, `order_id`, `price`, `quantity`, `tax_category_id`, `updated_at`, `variant_id`) VALUES (17.0, '2015-02-06 04:16:49', 'USD', 4, 15.99, 1, 1, '2015-02-06 04:16:49', 1)
Spree::Zone Load (0.2ms) SELECT `spree_zones`.* FROM `spree_zones` WHERE `spree_zones`.`default_tax` = 1 ORDER BY `spree_zones`.`id` ASC LIMIT 1
Spree::Adjustment Load (0.3ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE 1=0 AND `spree_adjustments`.`source_type` = 'Spree::TaxRate'
Spree::Adjustment Load (0.4ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::TaxRate'
SQL (0.3ms) UPDATE `spree_orders` SET `spree_orders`.`updated_at` = '2015-02-06 04:16:49' WHERE `spree_orders`.`id` = 4
Spree::Payment Load (1.9ms) SELECT `spree_payments`.* FROM `spree_payments` WHERE `spree_payments`.`order_id` = 4 AND (`spree_payments`.`state` NOT IN ('failed', 'invalid')) ORDER BY spree_payments.created_at
Spree::Zone Load (0.2ms) SELECT `spree_zones`.* FROM `spree_zones` WHERE `spree_zones`.`default_tax` = 1 ORDER BY `spree_zones`.`id` ASC LIMIT 1
Spree::Adjustment Load (0.1ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE 1=0 AND `spree_adjustments`.`source_type` = 'Spree::TaxRate'
Spree::Adjustment Load (0.1ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::TaxRate'
Spree::Adjustment Load (0.3ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::PromotionAction'
Spree::Adjustment Load (0.3ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::PromotionAction' AND `spree_adjustments`.`eligible` = 1 ORDER BY amount ASC, created_at DESC, id DESC LIMIT 1
CACHE (0.1ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::PromotionAction' AND `spree_adjustments`.`eligible` = 1 ORDER BY amount ASC, created_at DESC, id DESC LIMIT 1 [["adjustable_id", 6], ["adjustable_type", "Spree::LineItem"]]
Spree::Adjustment Load (0.4ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::TaxRate' AND `spree_adjustments`.`included` = 1
Spree::Adjustment Load (0.3ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_id` = 6 AND `spree_adjustments`.`adjustable_type` = 'Spree::LineItem' AND `spree_adjustments`.`source_type` = 'Spree::TaxRate' AND `spree_adjustments`.`included` = 0
(5.0ms) ROLLBACK
Completed 500 Internal Server Error in 194ms
TypeError - nil can't be coerced into Float:
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/item_adjustments.rb:63:in `update_adjustments'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/item_adjustments.rb:18:in `update'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/line_item.rb:141:in `recalculate_adjustments'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/line_item.rb:136:in `update_adjustments'
activesupport (4.1.8) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.8) lib/active_support/callbacks.rb:221:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.8) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.1.8) lib/active_record/persistence.rb:125:in `save!'
activerecord (4.1.8) lib/active_record/validations.rb:57:in `save!'
activerecord (4.1.8) lib/active_record/attribute_methods/dirty.rb:29:in `save!'
activerecord (4.1.8) lib/active_record/transactions.rb:273:in `block in save!'
activerecord (4.1.8) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
activerecord (4.1.8) lib/active_record/transactions.rb:208:in `transaction'
activerecord (4.1.8) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
activerecord (4.1.8) lib/active_record/transactions.rb:273:in `save!'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/order_contents.rb:84:in `add_to_line_item'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/order_contents.rb:10:in `add'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/order_populator.rb:37:in `attempt_cart_add'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/core/app/models/spree/order_populator.rb:16:in `populate'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-fd575479ca20/frontend/app/controllers/spree/orders_controller.rb:45:in `populate'
actionpack (4.1.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.8) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.8) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.8) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.8) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.8) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.8) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.8) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.8) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.8) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.8) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.8) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.8) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:678:in `call'
railties (4.1.8) lib/rails/engine.rb:514:in `call'
railties (4.1.8) lib/rails/railtie.rb:194:in `method_missing'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:678:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
xray-rails (0.1.14) lib/xray/middleware.rb:37:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/headers.rb:16:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/rack/error_collector.rb:50:in `traced_call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/rack/browser_monitoring.rb:19:in `traced_call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/flash.rb:254:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activerecord (4.1.8) lib/active_record/query_cache.rb:36:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.8) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/reloader.rb:73:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.8) lib/rails/engine.rb:514:in `call'
railties (4.1.8) lib/rails/application.rb:144:in `call'
railties (4.1.8) lib/rails/railtie.rb:194:in `method_missing'
newrelic_rpm (3.9.0.229) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.8) lib/rails/commands/server.rb:69:in `start'
railties (4.1.8) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.8) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.8) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.8) lib/rails/commands.rb:17:in `<top (required)>'
script/rails:6:in `<main>'
答案 0 :(得分:0)
关注https://github.com/spree/spree/blob/2-4-stable/core/app/models/spree/item_adjustments.rb line 63
:
:adjustment_total => promo_total + additional_tax_total,
我注意到promo_total
在 48 行中定义为:
promo_total = best_promotion_adjustment.try(:amount).to_f
我猜这里的best_promotion_adjustment.amount
值为null
。这可以解释错误:nil can't be coerced into Float
。