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

[BACKPORT] Reintroduce inverse_of: :product for variants association #4234

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

spaghetticode
Copy link
Member

Description

This PR is a backport of #4227 from master

inverse_of: :product was moved to the variants_including_master association with 7c37093, but there should be no problem in having this option specified in more than one association, in fact its removal is causing an issue as now the reference to the product changes is lost for records in the variants association:

p = Spree::Product.first
v = p.variants.first
m = p.variants_including_master.find_by(is_master: true)

p.name = "Foobar"

m.product.name
 # => "Foobar"

v.product.name
# => "Solidus T-Shirt"

Checklist:

`inverse_of: :product` was moved to the `variants_including_master`
association with 7c37093, but there shold be no problem in having
this option specified in more than one association, in fact its
removal is causing an issue and now the reference to the product
changes is now  lost for records in the `variants` association:

    p = Spree::Product.first
    v = p.variants.first
    m = p.variants_including_master.find_by(is_master: true)

    p.name = "Foobar"

    m.product.name
     # => "Foobar"

    v.product.name
    # => "Solidus T-Shirt"
@spaghetticode spaghetticode self-assigned this Jan 3, 2022
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@spaghetticode spaghetticode merged commit 4d1d5b8 into solidusio:v2.11 Jan 13, 2022
@spaghetticode spaghetticode deleted the v2.11 branch January 13, 2022 07:46
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

Successfully merging this pull request may close these issues.

3 participants