inertiajs / inertia-rails

The Rails adapter for Inertia.js.
https://inertia-rails.dev/
MIT License
574 stars 45 forks source link

Refactor inertia share to use instance variables #111

Closed PedroAugustoRamalhoDuarte closed 5 months ago

PedroAugustoRamalhoDuarte commented 7 months ago

Goal

This PR refactors how inertia_share is storage inside the request lifecycle.

Solution

The solution was to sticky with default rails conventions, using only instance variable to storage inertia_share data and using inertia_share as a wrapper to rails before_action

Future improves

buhrmi commented 7 months ago

wow that was fast

PedroAugustoRamalhoDuarte commented 7 months ago

@bknoles i see the problem with class_attribute and i refactor with this idea in mind: https://github.com/inertiajs/inertia-rails/pull/108#issuecomment-2050573597.

Basically using instance attributes and before_action, the CI is passing, but i think we need some more tests

bknoles commented 6 months ago

Want to review the code a bit more, but, as I mentioned in #115 , I'm leaning towards merging this!

PedroAugustoRamalhoDuarte commented 5 months ago

The tests that are failling in CI are bit flaky, i dont know if is a error in the test code or in the new controller implementation i can check better in this friday

waliffcordeiro commented 5 months ago

Great addition! Refactoring to stick with default Rails conventions by using instance variables to store inertia_share data and using inertia_share as a wrapper for before_action improves the clarity and maintainability of the code. Future enhancements, like supporting only and except features from before_action, would also be beneficial and add more flexibility. Good job!

bknoles commented 5 months ago

Great addition! Refactoring to stick with default Rails conventions by using instance variables to store inertia_share data and using inertia_share as a wrapper for before_action improves the clarity and maintainability of the code. Future enhancements, like supporting only and except features from before_action, would also be beneficial and add more flexibility. Good job!

Team support! I like it! 😀

bknoles commented 5 months ago

Released as part of 3.2.0!