Ich habe Probleme, dieses Problem zu lösen. Ich erhalte immer den gleichen Fehler:NoMethodError in Cloths # Index
(undefined method `id' for nil:NilClass):
Hier mein application.html
<% @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
Können Sie klären, welche Zeile den Fehler gibt? –