我想在我的application.html.erb中渲染部分内容。部分源自产品文件夹“产品/类别”。当我尝试在application.html.erb中插入一个部分时,如下所示,我得到#<#:0x007fcfa35c9c78>的未定义局部变量或方法`类别'。任何帮助是极大的赞赏。传入部分对象
application.html.erb
<%= render 'products/categories', locals: { categories: categories }%>
产品/ _categories.html.erb
<% @categories.each do |category| %>
<li><%= category %></li>
<% end %>
products_controller.rb
def categories
@categories = ProductCategory.all
end
我最后做的是刚刚创建的helper方法,并在_categories.html.erb引用它。我无法得到任何其他工作。 – RickD