我的应用程序中有一个按钮,通过点击它可以重定向到一个新窗口。下面是它的jQuery代码:在Rails中获取PDF中重定向页面的响应
jQ("#create_report").click(function() {
if (jQ('#client_id').val() !== "" &&
jQ('#report_date').val() !== "") {
window.open(
"/automated_reporting/report?clientId=" +
jQ('#client_id').val() + "&clientName=" +
jQ('#client_id option:selected').html() +
"&selectedDate=" + jQ('#report_date').val(),
'Report',
'height=700,width=750');
jQ('#modal_report').modal('hide');
} else {
jQ('#create_modal_notification').showMessage(
"error", "Provide Date and Report Type"
);
}
});
在我的控制,我已经写了什么重定向或渲染它,因为我已经在JavaScript这样做。该页面已成功重定向,并且输出也可以根据需要正确显示。但我想要的是以PDF格式打印重定向页面的输出。我试图在我的控制器的报告采取行动输入以下代码使用wicked_pdf
宝石吧:
respond_to do |format|
format.pdf do
render :pdf => "file_name"
end
end
end
但它只是给模板错误report.pdf不存在,双渲染错误,当我尝试别的东西。