Skip to content

Comments

Fix inverse of resolution#262

Merged
julianrubisch merged 6 commits intomainfrom
fix-inverse-of-resolution
Mar 2, 2023
Merged

Fix inverse of resolution#262
julianrubisch merged 6 commits intomainfrom
fix-inverse-of-resolution

Conversation

@julianrubisch
Copy link
Contributor

@julianrubisch julianrubisch commented Mar 1, 2023

Bug Fix

Description

This is more or less a reimplementation of a patch that @andrewculver made to fix inverse_of resolution. I just took it a bit further and lazy loaded/stored reflection properties in the finder, because it's useless to do the work twice, and declutters the main module a bit

https://github.com/stimulusreflex/cable_ready/compare/master...andrewculver:cable_ready:master?diff=split

(maybe) Fixes #258
awaiting confirmation from the BulletTrain team cc @andrewculver

Checklist

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing

@netlify
Copy link

netlify bot commented Mar 1, 2023

Deploy Preview for cableready ready!

Name Link
🔨 Latest commit a58af43
🔍 Latest deploy log https://app.netlify.com/sites/cableready/deploys/6400ee54bde7ad00083125e5
😎 Deploy Preview https://deploy-preview-262--cableready.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@julianrubisch julianrubisch requested a review from hopsoft March 1, 2023 13:44
@julianrubisch julianrubisch self-assigned this Mar 1, 2023
@julianrubisch julianrubisch added bug ruby Pull requests that update Ruby code labels Mar 1, 2023
@gazayas
Copy link

gazayas commented Mar 2, 2023

This solves #258 for me 🙇

@julianrubisch julianrubisch marked this pull request as ready for review March 2, 2023 07:51
raise ArgumentError, "Could not find inverse_of for #{collection[:name]}" unless collection[:inverse_association]
collection.reflection ||= collection.klass.reflect_on_association(collection.name)

collection.foreign_key ||= collection.reflection.foreign_key
Copy link
Contributor

Choose a reason for hiding this comment

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

We use safe navigation below on collection.reflection. Should we do the same here?

@julianrubisch julianrubisch merged commit 1e4afd8 into main Mar 2, 2023
@julianrubisch julianrubisch deleted the fix-inverse-of-resolution branch March 2, 2023 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inverse_of returns nil when enriching has_many association with updates

3 participants