In my index view I am looking to add a button that will execute a function called myFunction(myArg). This function is located in behaviours/myRubyFile.rb. How can I create a button that executes that function with a particular argument.
EDIT:
Now I am getting a new error
The action 'my_func' could not be found for FunctionsController
However there is a function my_func defined in FunctionsController.
Generally, you’d want to send a request to the server from that button, so the server runs myFunction. To achieve this follow these steps:
1 – make sure behaviours/myRubyFile.rb defines a module:
2 – define a route in routes.rb:
3 – define FunctionsController:
4 – create a button in the view to send the request to the server:
I haven’t tested this code, but it should do the trick.
EDIT: added
:arg => "YOUR ARG HERE"to the route (Thnx nzifnab)