1

这是我项目中视图的结构

app
  |
   - views
         | admin
               |
               sidebar.html.erb
         |
         layouts
               |
               admin.html.erb

admin.html.erb 的内容

<html>
<head>
  <title>Blog</title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>
    <div id="container"> <!-- Container begins here -->

<%= render "admin/sidebar" %>

<%= yield %>

    </div> <!-- END Content -->
</div> <!-- END Primary -->


<div class="clear"></div>
</div> <!-- END Container -->

</body>
</html>

我得到这个错误

Missing partial admin/sidebar with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
  * "/Users/me/blog/app/views"
  * "/Users/me/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/app/views"

我尝试了不同的侧边栏路径,但没有成功。

4

1 回答 1

1

它应该是“_sidebar.html.erb”。部分文件名需要以“_”开头。

于 2012-07-10T17:07:35.307 回答