You can't evaluate a JavaScript variable inside your Ruby method. Also, your current script has to be outside the asset pipeline, which is usually a bad practice.
One simple solution is to pass the variable as a data attribute. You would run your method, then pass the result with jQuery after the DOM has loaded. This allows you to keep JavaScript in the asset pipeline and pass it data evaluated by Ruby server-side.
Note: @b
should be defined on your controller:
<div id="foo" data-bar="<%= method.a(@b).to_s %>"></div>
<script>
$(document).ready(function() {
var b = $(#foo).data('bar');
var c = "string" + b;
});
</script>
The other option is to render your script asynchronously with unobtrusive JavaScript in Rails.