Ruby on Rails #144 Why I am replacing Turbo Frames with Streams for ActsAsVotable?

about 1 month ago
ruby rails ruby on rails tutorial programming hotwire turbo streams turbo frames voting
Sign in to track your progress

Some server-side rendering problems can be equally solved by either Turbo Frames or Streams.
Each approach has it's cons and pros.

In this scenario I first implemented Voting with Turbo Frames.
This invoked quite a lot of extra context and calculations when calling a separate posts_controller#show action.
So I replaced Frames with Streams that required no extra context outside the current controller action, and explicitly defined the expected server-side rendered HTML (turbo stream) response.

0:00 How ActsAsVotable is set up on
3:28 Turbo Frame refreshes vote buttons
4:50 Turbo Frames grabs new context
5:24 Turbo Streams response to replace Frames
8:37 Conclusion: choose the best tool for the job!

Sign in to join the conversation

Loved it!
Simple and easy!

Adrian Marin Adrian Marin about 1 month ago