Google query doesn't give much useful result on this topic. What we discuss here is if there is a value/function
"message = hello_world" (a URL query). How do you pass the JS variable into controller?
Most common way is using
link_to_remote which constructs an Ajax call, but the drawback is you have to handle the
params[:message] using RJS template (or please let me know if I was wrong). Here is the example:
As you see, the :with option will eventually become
:with => "message=hello_world". A new parameter is accessible by calling
params[:message]. But what if I only want to render another page?
@param variable is readable in the view.
@param variable, it is used here. An inline
redirect_to does the trick, that redirects to the
new action and value is accessible by calling
I'm sure that you will have other ways of using these tricks in difference situation, but hope you get the idea and use them whenever is suitable.