I have what seems like a straight forward problem, I want to be able to change arguments on a link_to to something the user picks. My app does not require a login so the usual methods of setting user prefs on login arn’t appropriate. The user selects an option from a select_tag like so (I’m using Haml);
= select_tag('bible_version', options_for_select(['NIV','ESV', 'MSG'], :selected => @bible_version))
Here is part of my index view with the link_to;
- @verses.each do |verse|
%tr
%td= verse.gospel_verse
%td= link_to 'Read', 'http://www.biblegateway.com/passage/?search=' + verse.gospel_verse + '&version=' + @bible_version
What would be the best way to change the @bible_version variable to the value the user chose and reset all the links? I figure I need to set a cookie and dont mind doing a page refresh or using Javascript, but I cant get my brain around a clean way to do this. Thanks in advance for any help!
I didn’t test the below code, but seems like it would work in your on load function.