stimulusreflex / stimulus_reflex

Build reactive applications with the Rails tooling you already know and love.
https://docs.stimulusreflex.com
MIT License
2.28k stars 172 forks source link

Lost Instance Variables #471

Closed jonsgreen closed 3 years ago

jonsgreen commented 3 years ago

Describe the bug

Calling controller in a before_reflex keeps instance variables set in the reflex from being accessible in the view. Discord conversation here.

To Reproduce

Here is an MVCE to demonstrate the behavior: https://github.com/jonsgreen/stimulus_reflex_input_bug/tree/lost-instance-variables-bug.

If you update the message comment you will see that the message is updated but the @comment set in the does not transfer to the view. If you comment out: https://github.com/jonsgreen/stimulus_reflex_input_bug/blob/lost-instance-variables-bug/app/reflexes/message_reflex.rb#L4 then it does.

Expected behavior

Expect all instance variables set in a reflex to be available when rendering.

Screenshots or reproduction

Versions

StimulusReflex

External tools

leastbad commented 3 years ago

Hi Jonathan,

493 should address this. If you have a second, let me know what you think!