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实际上并没有调用动作;我已经定义了必要的路线。

4

1 回答 1

3

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

于 2012-11-28T10:27:14.540 回答