Prototype’s Ajax accepts a parameter called ‘parameters’ with an hash array for parameters (prototype doc) which would automatically be sent as GET or POST vars, but I could not find how to add items to that array using the Rails button_to_remote method.
I could just add the parameters to the URL sent to the method, but that feels hackish.. Is there a better solution out there?
I actually found the solution! You can pass parameters in the function using the :with option, like this:
The trick is that the value for :with is a javascript expression that should return a key-value pair in the URL format, like “key=value”. That’s why there’s extra quotes around the value on the same above.
A function could also be used to pull the information from the page, if necessary:
The function will be evaluated before the form is submitted.