【发布时间】:2013-02-18 07:53:03
【问题描述】:
我的应用中有一个按钮,通过单击它会重定向到新窗口。这是它的 jQuery 代码:
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 gem:
respond_to do |format|
format.pdf do
render :pdf => "file_name"
end
end
end
但是当我尝试别的东西时它只是给出模板错误report.pdf不存在和双重渲染错误。
【问题讨论】:
标签: jquery ruby-on-rails pdf-generation wicked-pdf