我有两个控制器,foo
和bar
。
bar#dobar
有一个相应的dobar.js.erb
文件,当使用
*/*;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]
怎么了?
答案 0 :(得分:0)
如果您只是调用模板而不是操作,请尝试此操作
render :template => 'bar/dobar', :format => [:js]