Save 36% for Black Friday! Learn more

New Discussion

Notifications

You’re not receiving notifications from this thread.

Anchors being ignored when added to redirect_to path in controller

2
Rails

I feel I am missing something fundamental, or maybe just silly, when it comes to this issue.

I am utilizing linking to anchors in most places in an app I am building and all is working well with links in the view. Formatting my path like...

sample_path(anchor: "sample_anchor")

When I attempt this via my controller via a patch method it is not taking you to the anchor when the page is loaded. Setup in my controller for the redirect_to is like...

redirect_to some_page_path(anchor: "some_anchor"), notice: "Some notice"

I had to change my link to a button and set data-turbo to false in order for it to respond to what I needed it to.

Oh my gosh RJ! Thank you!! (I signed up to GoRails just so I could thank you!)
I honestly have been dealing with this issue for HOURS, when I finally came across your post!
I mean it should be as simple as adding an anchor tag to your redirect path, right? WRONG, if you're using turbo-streams. 🀦🏻 Didn't even think of adding data { turbo: false } to my button. 🀦🏻 Thank you, thank you! πŸ€©πŸ™ŒπŸ»

Join the discussion
Create an account Log in