Solidus: Spree::Shipment#cartons is an array

Created on 27 Mar 2018  路  2Comments  路  Source: solidusio/solidus

This is happening because the cartons association in Spree::Shipment uses uniq instead of distinct, and uniq returns an array as of Rails 5.1.

The following monkey-patch fixes the problem:

Spree::Shipment.class_eval do
  has_many :cartons, -> { distinct }, through: :inventory_units
end

Steps to reproduce

  • Call Spree::Shipment#cartons in any Solidus app

Expected behavior

An AR collection proxy should be returned.

Actual behavior

NoMethodError: undefined method `extensions' for []:Array
Did you mean?  extend
from /Users/aldesantis/.rvm/gems/ruby-2.5.0@myproject/gems/activerecord-5.1.5/lib/active_record/associations/association.rb:140:in `extensions'

System configuration

Solidus Version: 2.3

Extensions in use:

  • solidus_affirm
  • solidus_auth_devise
  • solidus_comments
  • solidus_gateway
  • solidus_paypal_braintree
  • solidus_product_assembly
  • solidus_redirector
  • solidus_related_products
  • solidus_reviews
  • solidus_sale_prices
  • solidus_sendwithus
  • solidus_sitemap
  • solidus_social
  • solidus_static_content
  • spree_paypal_express
  • solidus_trackers
Beginner-Friendly

Most helpful comment

I can do this? I want start in the open source world.

All 2 comments

I can do this? I want start in the open source world.

Fixed by #2653

Was this page helpful?
0 / 5 - 0 ratings