0
我已經在控制器中定義的方法是這樣的:缺少模板動作錯誤
def self.dailymail
.... #fill data from db
ac = ActionController::Base.new()
kit = PDFKit.new(ac.render_to_string(:action => "formatinhtml.html.erb",:rawdata => data))
pdf = kit.to_pdf
... #send pdf in mail
end
formatinhtml是這樣的:
def formatinhtml
@dailyrep = params[:rawdata]
respond_to do |format|
format.html # daily.html.erb
end
end
我必須使用self.dailymail,這樣我可以調用它從模型&轉而來自rufus調度器。
但是,我仍然得到錯誤,如:
scheduler caught exception:
Missing template action_controller/base/daily.html with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :xls], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "F:/DEVELOPMENT/TrackIt/app/views"
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_view/path_set.rb:58:in `find'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_view/lookup_context.rb:109:in `find'...
那麼,什麼是我需要做什麼?
更新:調試後,我發現動作formatinhtml
實際上沒有被獲取調用;我已經定義neccessary路線。
模板動作錯誤通常意味着你有問題 – Richlewis
動作沒有相應的看法,但我有看法daily.html.erb – usercr