Ask A Question

Notifications

You’re not receiving notifications from this thread.

Hotwire prevents link_to from going to a different website

Fatumata Jalloh asked in General

I recently added Hotwire to my rails app to update modals but this broke a link_to I had that redirected users to stripe. I looked online for ways to work around it but since Hotwire is relatively new, I couldn't find it. Does anyone have any recommendations on getting link_to to work with turbo stream?

Reply

Use target="_top" as shown in https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb:
<%= turbo_frame_tag "tray", src: tray_path(tray), target: "_top" %>
The issue is that Turbo Frames hijacks links as described quite well here: https://blog.cloud66.com/taking-rails-to-the-next-level-with-hotwire/

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.