# No such file or directory - layouts/application.html.erb

**URL:** <https://www.ruby-forum.com/t/no-such-file-or-directory-layouts-application-html-erb/164277>\
**Category:** Rails\
**Created:** [March 30, 2009, 8:43pm UTC](https://www.ruby-forum.com/t/no-such-file-or-directory-layouts-application-html-erb/164277 "2009-03-30T20:43:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 30, 2009, 8:43pm UTC](https://www.ruby-forum.com/t/no-such-file-or-directory-layouts-application-html-erb/164277/1 "2009-03-30T20:43:55Z")

</div>

This is very frustrating. I am defining a layout for my  
AdminsController class index action which is as follows:

class AdminsController \< ApplicationController

before\_filter :signal\_child\_menu  
#current\_tab :admin

def index  
@child\_menu = true  
@search\_field = “name”  
@crust\_types = CrustType.search(params[:search], params[:page],  
@search\_field)  
render :template =\> ‘crust\_types/index’  
end

end

Note that the above action uses a different controller/index  
combination, i.e., CrustTypeController/index in this case.

I am defining a :secondary\_nav symbol in application.html.erb layout  
template as shown below:

```
        <div class='secondary-navigation'>
          <%= yield :secondary_nav %>
          <div class="clear"></div>
        </div>

```

So to define contents for the symbol :secondary\_nav, I created a  
specific layout template for the admins controller called  
admins.html.erb whose contents are shown below:

\<% content\_for :secondary\_nav do %\>  
\<%= navigation [:crust\_types, :toppings] %\>  
\<% end %\>  
\<%= render :file =\> “layouts/application” %\>

I am getting an error when I click on the Admins tab in my primary  
navigation menu:

No such file or directory - layouts/application

Extracted source (around line #4):

1: \<% content\_for :secondary\_nav do %\>  
2: \<%= navigation [:crust\_types, :toppings] %\>  
3: \<% end %\>  
4: \<%= render :file =\> “layouts/application” %\>

I do not understand why am I getting this error. The application is  
using Rails 2.1.2, but I have another application which is on Rails  
2.1.0 and uses similar technique to render combination layouts without  
any problems.

What is it that I am missing here?

Thanks for your help.

Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 30, 2009, 8:58pm UTC](https://www.ruby-forum.com/t/no-such-file-or-directory-layouts-application-html-erb/164277/2 "2009-03-30T20:58:22Z")

</div>

On Mar 30, 11:43 am, Bharat R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> What is it that I am missing here?

\<%= render :file =\> “layouts/application” %\>

That comports with your error, right? Seems too simple of a solution,  
but keep in mind that the application layout will be used  
automatically anyway, if there isn’t one for the current controller.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 30, 2009, 9:08pm UTC](https://www.ruby-forum.com/t/no-such-file-or-directory-layouts-application-html-erb/164277/3 "2009-03-30T21:08:46Z")

</div>

Eric wrote:

> On Mar 30, 11:43ï¿½am, Bharat R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > What is it that I am missing here?
> 
> \<%= render :file =\> “layouts/application” %\>
> 
> That comports with your error, right? Seems too simple of a solution,  
> but keep in mind that the application layout will be used  
> automatically anyway, if there isn’t one for the current controller.

Hello Eric,  
You are seeing something obvious that escapes me, hence the frustration.  
This is contained in my admins.html.erb file which in turn is stored in  
app/views/layouts directory off the Rails root directory.  
application.html.erb is the main layout file in the same directory. All  
I am doing is defining the :secondary\_nav symbol using content\_for and  
then delegating to the default application layout file. So why is rails  
complaining?  
Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 30, 2009, 10:34pm UTC](https://www.ruby-forum.com/t/no-such-file-or-directory-layouts-application-html-erb/164277/4 "2009-03-30T22:34:13Z")

</div>

Got it. I had to say:

\<% content\_for :secondary\_nav do %\>  
\<%= navigation [:crust\_types, :toppings] %\>  
\<% end %\>  
\<%= render “layouts/application” %\>

Note that I deleted the word “file” from the last statement which was:

\<%= render file “layouts/application” %\>

I have no idea why it works in the other application where I assemble  
layouts using dynamic headers and footers using the same technique which  
uses render file instead of just render statements.

Another of Rails “hidden” features I suppose?
