-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Updates for Attachments #190
Updates for Attachments #190
Conversation
57fd0d3
to
5f0f7bd
Compare
Thanks @andrewerlanger for taking this on, this is a great addition that I've been thinking about myself for a long time already 🙏 Two questions right off the bat:
|
}) | ||
end | ||
|
||
def enrich_attachments_with_updates(name, option) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! The only caveat is that this class has grown a long beard up till now. I think there's an opportunity to factor out some of the Association
/ ActiveStorage
related stuff here... let me ponder that a bit...
I agree that it would be nice to see support for Nice work, @andrewerlanger! |
@julianrubisch @leastbad thanks for the quick turnaround on the review 🙏 I'll add a test for Should have something to share by mid-next week :) |
@andrewerlanger adding a test should suffice for this one. I'll think about what architecture the different options should have later... |
Just wanted to poke because this PR is cool and I'd love to see it hit the ground running for 5.0. |
Just a quick update: @andrewerlanger I checked out your branch to check if I could add a test real quick, but for me it turned out that I dug a bit into ActiveStorage code and it turns out, that, I believe, we'd have to set the However, that Would love to hear everyone's thoughts on this... |
@julianrubisch @leastbad apologies for the delay on this one – I have a nasty habit of overestimating how much free time I'll have up my sleeve whenever I go on vacation 🙈 In any case, I've added a couple of tests for @julianrubisch as for the lack of broadcasting you mention here...
...are you sure this is actually the case? I unfortunately don't have time to dig into it in detail right now, but I tested the extended As always, it's very possible I'm wrong about this though. Please feel free to update the PR accordingly if that's the case here! |
It decidedly didn't work for me, but I could have also missed something very basic and would be the happiest person if it did! I'll take another look! |
Alright, I don't know what I was missing there. Merging! |
Enabling updates on associations is one of the many great powers that
updates_for
confers. This PR takes a stab at extending that power to Active Storage attachments, along the lines of the following:Specifically: it adds an
enrich_attachments_with_updates
method, which borrows heavily fromenrich_association_with_updates
to register the attachments within theCollectionsRegistry
.I've done some manual testing and the updates seem to work as you would expect (i.e. in the same way they do for the existing collection logic –
has_many :posts, enable_updates: true
).That said, I'm not sure if there are any edge-cases or customizations related to Active Storage that could make this a little brittle. I couldn't find any obvious red flags in the Active Storage docs, but that doesn't mean they don't exist 🤔