rubyeventshyperlinkvoltrbopalrb

Fire an action when a link gets clicked to a page that has the same action (VoltRb)


At http://localhost:3000/books, I have an index page where I have a list of books.

enter image description here

When you click on one of the links, the action to which it is bound, book, gets fired:

enter image description here

However, when you click on one of the links from one of the book pages, the book action doesn't get fired:

enter image description here

Note that the URL does change when the links are clicked, from both the index page and the book pages, but the problem that I'm having is that book doesn't get activated when you click on a link to a book page from another book page. How can I fix a situation like this?

FYI, here is a repo where this problem can be reproduced.


Solution

  • As it turns out, Volt computations are a way to solve this problem. By using the params collection, you can attach computations to changes in the URL. I solved this issue and got book to run on changes in the URL like so: https://github.com/ylluminarious/volt_action_problems/commit/5fcefc16d7b14a980f68ce572a80f25540d21636.