rails3中缺少模板操作错误

时间:2012-11-28 07:36:22

标签: ruby-on-rails ruby actionview actioncontroller rufus-scheduler

我在控制器中定义了一个方法,如:

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,以便我可以从model&从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实际上没有被调用;我已经定义了必要的路线。

1 个答案:

答案 0 :(得分:3)

“daily.html”所在的文件夹与您的控制器不同