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 #4236

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

spaghetticode
Copy link
Member

Description

This is a backport from master of #4227

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
@waiting-for-dev waiting-for-dev merged commit ec70104 into solidusio:v3.1 Jan 5, 2022
@waiting-for-dev waiting-for-dev deleted the v31/reintroduce-inverse-of branch January 5, 2022 04:36
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