MissingTemplate : Render partial in Rails 3.2.3

5.1k views Asked by At

Hi I am new to Ruby on Rails and I am following Michael Hartl's book online. In Partials section of his book. The code he used to render partial was

<%= render 'layouts/stylesheets' %>

but I get this error.

I read the API and tried this

<%=render :partial => "/layouts/stylesheets" %>
but still can't figure this one out.

Thanks for all the help!

2

There are 2 answers

1
markphd On BEST ANSWER

I overlooked the filename. When I initially created the file, after the .erb extension, I accidentally put a space after.

3
Ben On

In your view, make sure you have the following structure:

- views
  - layouts
    - application.html.erb
    - _stylesheets.html.erb

Your code should be:

<%= render 'layouts/stylesheets' %>

If your main template is inside the layouts folder:

<%= render 'stylesheets' %>