In my ideal scenario, this is the code I wish for:
inside my controller action:
@javascript_function_args = [ "foo", "bar", 1, [2, 3], { :zort => 'narf', :nom => 'cake' }]
within my erb view:
<script … >
performAwesome(<%= @javascript_function_args.to_js_args %>);
</script>
or, even better:
<%= call_javascript_function :performAwesome, *@javascript_function_args %>
the expected outcome:
<script … >
performAwesome("foo", "bar", 1, [2, 3], { zort : 'narf', nom : 'cake' });
</script>
I could simply use #to_json
on the array and remove the enclosing brackets, but I am curious if there's a more tailored solution available.