Load relationships on inserted ressource

I was wondering if there was a way to load relationships by default on an inserted ressource after a successful submit of a for_create form? The goal here is to simply append that newly inserted ressource to a list afterwards, but I need some relationships to be loaded on that ressource. I know I can do it manually, but I was wondering if there was a way to define some defaults "load" somewhere? Thanks a lot in advance 🙂
5 Replies
kernel
kernel•3y ago
you can do it on the resource preparations block, not 100% sure if that runs after a create
richaard0
richaard0OP•3y ago
Yes, I should have mentioned that I did try that but it didn't work unfortunately. I assume that this is because there isn't an actual read query being done
preparations do
prepare build(load: [:departure_airport, :arrival_airport])
end
preparations do
prepare build(load: [:departure_airport, :arrival_airport])
end
kernel
kernel•3y ago
how about custom change set on after_action which loads it?
ZachDaniel
ZachDaniel•3y ago
There is a builtin change change load(:foo)
richaard0
richaard0OP•3y ago
I did not see that one, but it works perfectly! Thanks! 😄

Did you find this page helpful?