ActionView::TemplateError (Missing template) In ruby on rails

wael34218 picture wael34218 · Feb 24, 2011 · Viewed 23.1k times · Source

I am running a RoR application (rails 2.3.8, ruby 1.8.7), the application runs fine on my local machine. but on production the logs show the following error:

ActionView::TemplateError (Missing template folder/_file_name.erb in view path app/views) on line #19 of app/views/layouts/main.rhtml:
19:     <%= render :partial => "folder/file_name" -%>

the file name exists as folder/_file_name.html.erb, I tried to reproduce the problem on the production environment but didnt have any luck, for some reason rails application asks for folder/_file_name.erb at some times while other times it searches for the right file folder/_file_name.html.erb.

Could someone explain to me what is going on?

The same also occurs for .rhtml files, rails application requests .erb at times while others get the right .rhtml file

update:

<%= render :partial => "shared/meta_tags" -%>
<%= render :partial => "shared/common_resources" -%>
<%= render :partial => 'shared/ads/oas' -%>

Any pointers on this issue will be helpful, thanks in advance

Answer

Fernando Diaz Garrido picture Fernando Diaz Garrido · Feb 24, 2011

Whats the format of the request?, for the first template (folder/_file_name.html.erb) it will only be correct if the request format is html, but not if it is ajax or any other custom type you have in your app. One quick soluction would be to rename it to folder/_file_name.erb if you want to use the same partial for all the formats