Ruby on rails Excel和Pdf不在RoR中工作
在我的应用程序中,我必须附加excel和pdf,但它是通过一个错误Ruby on rails Excel和Pdf不在RoR中工作,ruby-on-rails,Ruby On Rails,在我的应用程序中,我必须附加excel和pdf,但它是通过一个错误 ActionView::MissingTemplate: Missing template self_services/show, application/show with {:locale=>[:en], :formats=>[:xls], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :axlsx, :jbuilde
ActionView::MissingTemplate: Missing template self_services/show, application/show with {:locale=>[:en], :formats=>[:xls], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :axlsx, :jbuilder]}. Searched in:
下面是我的控制器代码-
def show_self_datewise_attendance
@from = params[:employee][:from]
@to = params[:employee][:to]
@employee_attendances = EmployeeAttendance.where(day: @from.to_date..@to.to_date,employee_id: current_user.employee_id)
respond_to do |format|
format.js
format.xls {render template: 'self_services/datewise_attendance_report_xls.xls.erb'}
format.html
format.pdf do
render pdf: 'datewise_attendance_report_pdf',
layout: 'pdf.html',
orientation: 'Landscape',
template: 'self_services/datewise_attendance_report_pdf.pdf.erb',
# show_as_html: params[:debug].present?,
:page_height => 1000,
:dpi => '300',
:margin => {:top => 10, # default 10 (mm)
:bottom => 10,
:left => 20,
:right => 20},
:show_as_html => params[:debug].present?
end
end
end
您的
自助服务/datewise出勤报告\u xls.xls.erb
实际上是什么样子的?根据您发布的错误,无法找到该文件。我过去成功地遵循了这一点,没有任何问题。试试这个,希望它能起作用。到目前为止,你有什么解决方案吗?没有,还没有@aniketshivamtiwary。试试这个datewise考勤报告。erb是自助服务表中的excel页面。据我所知,它必须是文件系统中的一个文件。在该路径上是否存在视图模板(即文件)?另外,FWIW,我让它在没有模板的情况下工作(只是一个视图)。您可能需要使用Mime::Type.register“application/xls”,:xls
来完成这项工作,而不需要模板(根据上面的Railscast)。