I need to seed a javascript variable to the controller. For example, if my code in the view is the following –
... <script type="text/javascript">
variable_test = 'hello'
</script>
...
I need the controller to get variable_test , like –
def hello
@variable_test = #Some code
# @variable_test => 'hello'
end
The view is hello of course, and ‘Some code’ is what I don’t know how to do.
You can’t send client side code to the controller unless you do a get, or post, of some sort. Try using jQuery’s post or get methods. If you aren’t using jQuery then you can do something like this:
then in your controller you would do:
The syntax may be a bit off, but you get the general idea.