NoMethodError in Fabrics#category

Showing /var/www/justform/app/views/fabrics/_category.html.erb where line #4 raised:

private method `select' called for nil:NilClass
Extracted source (around line #4):
2
3
4
5
6
7
              
<div class="fake-link item__img_wrapper" onclick="document.location.href='<%= fabric_path(@fabric) + "/" + category.slug + '.html' %>';">
<picture class="item__img">
<% category_products = @image_products.select { |x| x.category_ids.include?(category.id) }.sort_by(&:created_at) %>
<% category_products_uniq = category_products %>
<% unused_category_product = category_products.select { |x| @used_products.exclude?(x.id) }.last %>
<% unused_category_product.blank? ? (unused_category_product = category_products.last) : @used_products << unused_category_product.id %>

Trace of template inclusion: #<ActionView::Template app/views/fabrics/_filter_show.html.erb locals=[]>, #<ActionView::Template app/views/fabrics/show.html.erb locals=[]>

Rails.root: /var/www/justform

Application Trace | Framework Trace | Full Trace

Request

Parameters:

{"category"=>"stoly", "subcategory"=>"kofeinye-stoliki", "fabric"=>"arlex-italia", "format"=>"html"}

Response

Headers:

None