I am trying to inject the filename JavaScript variable into my Ruby code like this:
"#{ajax_download_report_url(" + filename+ ")}"
It's a basic route URL but I need to pass this variable in HAML because I get it from this Ajax request:
:javascript
var updaterId = setInterval(function() {
$.ajax({
url: #{admin_reports_url.to_json},
dataType: "json",
type: "GET",
data: {job_id: "#{job_id}"},
success: function(response){
var filename = response.file;
switch(status) {
case 'failed':
$('.loader').hide();
clearInterval(updaterId);
alert(message);
break;
case 'completed':
$('.loader').hide();
clearInterval(updaterId);
location.href = "#{ajax_download_report_admin_reports_url(" + filename+ ")}";
break;
}
}
})}, 1000);
Now I have an error:
ActionController::RoutingError - No route matches
{:controller=>"admin/reports", :action=>"ajax_download_report", :file=>" + filename+ "}
which means that HAML can't properly evalute this code.
#{...}.