Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spree::Shipment#cartons is an array #2653

Closed
aldesantis opened this issue Mar 27, 2018 · 2 comments
Closed

Spree::Shipment#cartons is an array #2653

aldesantis opened this issue Mar 27, 2018 · 2 comments

Comments

@aldesantis
Copy link
Member

aldesantis commented Mar 27, 2018

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
@Leoxxid
Copy link

Leoxxid commented Mar 29, 2018

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

@jhawthorn
Copy link
Contributor

Fixed by #2653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants