この問題を解決するには問題があります。ここに私のapplication.htmlをNoMethodError in Cloths#index
(undefined method `id' for nil:NilClass):
<% @categories.each do |category| %>
<li><a><%= link_to 'category.title', category_cloth_path(@category)%></a></li>
<%end%>
cloths_controller.rb
def index
@cloths = Cloth.all
@categories = Category.all
end
def show
@cloths = Cloth.all
@categories = Category.where("category_id = ?", @category.id)
@comments = Comment.where("cloth_id = ?", @cloth.id)
@comments = Comment.paginate(:page => params[:page], :per_page => 3)
end
エラーが発生している行を明確にすることはできますか? –