Hotwire Discussion

Turbo streams get request

Hi all,

I’m using turbo streams on a regular get request, how can I prevent turbo from changing the url? Or do I need to wrap the link with a frame?


In view:
<%= link_to “Toggle”, toggle_platform_path(platform) %>

In controller:
def toggle
respond_to do |format|

if you’re using turbo stream template responses you dont need to wrap anything, could you show a bit of your controller, turbo-stream template or something else ?

I guess you need to do XHR when you want to do a get for turbo stream.

You have 2 options:

  1. Use button_to insted of link_to

button_to "Toggle", toggle_platform_path(platform), method: :get

  1. Implement Stimulus Controller and pass text/vnd.turbo-stream.html as as MIME type

Could you elaborate more on setting the mime type via a stimulus controller, thanks

@dixpac The button_to didn’t work, it issues a regular HTML (not a TURBO STREAM) request