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

Reintroduce inverse_of: :product for variants association #4227

Merged

Conversation

spaghetticode
Copy link
Member

@spaghetticode spaghetticode commented Dec 21, 2021

Description

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 Dec 21, 2021
@spaghetticode spaghetticode marked this pull request as ready for review December 21, 2021 15:12
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.

I can't recall anymore why I did that change, but I'd swear it was because of some issue. However, CI is green! I'm ok with merging that and revisiting if we find a problem later on 🙂

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

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

Seems fine if it doesn't cause issue. If we find an issue we'll just have to make sure we add a spec for it.

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