2012-07-12 103 views
0

我有兩個控制器,foobarrender:action raise ActionView :: MissingTemplate

bar#dobar具有相應dobar.js.erb文件,它正確呈現當與

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

foo#dofoo完成當對命令render :action => '/bar/dobar' Accept首部直接調用。這將導致以下錯誤消息:

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

如果你只是想使用模板那就不叫渲染:行動改爲調用呈現:模板直接。我希望這會解決你的問題。 – Arun 2012-07-12 05:39:25

回答

0

試試這個,如果你只是調用模板不動作,

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

根據http://guides.rubyonrails.org/layouts_and_rendering.html#using-render上的文檔,這應該起作用,而且確實沒什麼區別。當我使用'render:template'時,我也收到了一個類似的「缺失模板」消息。 – bdares 2012-07-12 08:49:25

+0

你的錯誤應該是不同的我的意思是「缺少模板」你可以展開你更改爲模板後得到的錯誤消息嗎? – Arun 2012-07-12 09:01:21

+0

阿倫你能解決這個問題嗎? – praveenkumar 2017-02-10 06:26:13

相關問題