Jquery PDF不是在PDF中生成的
我是rails新手,我想将html页面转换为pdf。我正在使用wicked_pdf gem。我的问题是pdf应该为两种类型的用户(经理、员工)生成。对于普通员工,pdf是正确生成的。但是当经理试图生成pdf时,他不能;我已经给出了我的密码 这是我的控制器Jquery PDF不是在PDF中生成的,jquery,ruby-on-rails,ajax,pdf,wicked-pdf,Jquery,Ruby On Rails,Ajax,Pdf,Wicked Pdf,我是rails新手,我想将html页面转换为pdf。我正在使用wicked_pdf gem。我的问题是pdf应该为两种类型的用户(经理、员工)生成。对于普通员工,pdf是正确生成的。但是当经理试图生成pdf时,他不能;我已经给出了我的密码 这是我的控制器 @time_entries = TimeEntry.find(params[:ids]) @project = Project.find_by_id(params[:project_id]) @upcoming_week_t
@time_entries = TimeEntry.find(params[:ids])
@project = Project.find_by_id(params[:project_id])
@upcoming_week_tasks = @project.issues.open
opened_risks = Risk.where(project_identifier: @project.identifier, status: Risk.get_open_statuses )
closed_risks = Risk.where("project_identifier = ? and updated_at >= ? and updated_at <= ? and status in (?)", @project.identifier, params[:wsr_start_date],params[:wsr_end_date], Risk.get_closed_statuses)
@risks = opened_risks + closed_risks
respond_to do |format|
format.js do
render :partial => "wsr_entries", :content_type => 'text/html'
end
format.pdf do
render pdf: "PRR-#{@project.name}", template: "wsr/prr.html.erb"
end
end
end
视图中的链接标记是
<% action_path = @managers.include?(@user) ? get_prr_path(:format => "pdf") : weekly_status_report_path(:format => "pdf")%>
<p id="pdf_link" style="display:none;"><%= link_to "Download PDF", action_path %></p>
我想问题在于ajax函数
提前感谢并对我的英语不好表示歉意:)尝试将
format.html
添加到您的respond\u to
块中。我想,wicked\u pdf
希望它在那里,即使你不使用它
respond_to do |format|
format.html
format.js do
render :partial => "wsr_entries", :content_type => 'text/html'
end
format.pdf do
render pdf: "PRR-#{@project.name}", template: "wsr/prr.html.erb"
end
end
尝试将
format.html
添加到respond\u to
块中。我想,wicked\u pdf
希望它在那里,即使你不使用它
respond_to do |format|
format.html
format.js do
render :partial => "wsr_entries", :content_type => 'text/html'
end
format.pdf do
render pdf: "PRR-#{@project.name}", template: "wsr/prr.html.erb"
end
end
respond_to do |format|
format.html
format.js do
render :partial => "wsr_entries", :content_type => 'text/html'
end
format.pdf do
render pdf: "PRR-#{@project.name}", template: "wsr/prr.html.erb"
end
end