views:

41

answers:

2

I'm getting the following error when Rails tries to render my layout located in app/views/layouts/application.html.erb:

Missing template shared/_header.erb in view path /home/me/checkout/site/app/views: Extracted source (around line #11):
8: <body>
9: <div id="wrap">
10: <div class="clear">...</div>
11: <%= render :partial => 'shared/header' %>

What's weird about all of this is that I have a directory named shared inside of app/views. Inside there I have a file named _header.html.erb. I'm using Ruby 1.8.7, Rails
2.2.2, and following the documentation found here.

Update: Even more weirdness. This code works under Windows using InstantRails (Ruby 1.8.6, Rails 2.2.2). However, render :template doesn't seem to work. I'll keep on investigating.

+2  A: 

If what you typed is correct, your partial is misnamed. It should be "_header.html.erb" and not "_header.erb.html". This is probably why Rails is not finding it.

Pete
Thanks for pointing it out. It was a typo in the question. The filename is correct.
enriquein
A: 

It has been quite a while since I have touched Rails 2.2, but I believe that you are looking for the following:

<%= render :template => 'shared/header' %>

Edit: To whoever else is down down voting this, try reading the 2.2.2 docs and actually trying it first. This was a big gotcha back then.

jdl
According to the docs :template was required on Rails 2.2.2. Why they only mention it in a dark corner of the document is beyond me. I'm going to try this tonight at home. Also, I mistakingly downvoted your answer and just noticed now that the vote is locked. Please edit your answer so I can undo the downvote.
enriquein
@enriquein That's cool. Give it a shot, and if it doesn't solve your problem then the next step would be to post some logs.
jdl
Right! Logs! Why didn't I think of that before? I was pretty much just reading Mongrel's output, but I keep forgetting the logs.
enriquein