渲染 :action 引发 ActionView::Missing Template



我有两个控制器,foobar

bar#dobar有一个相应的dobar.js.erb文件,当直接调用时,该文件使用 accept 标头

*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript

foo#dofoo以命令 render :action => '/bar/dobar' 完成。 这会导致以下错误消息:

ActionView::MissingTemplate (Missing template foo/bar/action, /application/bar/action with {:locale=>[:en], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text,
 :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee]}. 
Searched in:
  * "/Developer/Workspace/MyProj/app/views"
  * "/Users/bdares/.rvm/gems/ruby-1.9.3-p194/gems/twitter-bootstrap-rails-2.1.0/app/views"
):
  app/controllers/foo_controller.rb:16:in `dofoo'

我也试过:

  • render :action => '/bar/dobar', :format => [:js]
  • render :action => 'bar/dobar'
  • render :template => '/bar/dobar', :format => [:js]

怎么了?

如果您只是调用模板而不是操作,请尝试此操作,

render :template => 'bar/dobar', :format => [:js]

最新更新