I’m using rails version 3.2.6 and I’m trying to pass a Javascript variable to another page “Test10”. I have the following code in the view:
<script>
var message = "hello world!";
</script>
<%= link_to "Go!", Test10_path(), :with => "'message='+ message" %>
The parameter is not passed to Test10. I have the following in the Test10 controller:
def Test10
@hello = params[message]
end
Is this the right way to pass a Javascript variable to my rails controller? It is not working. I’d appreciate any pointers. Thanks!
Something like this should work. Although most of the time, it’s best to pass params by using forms instead …