未定義方法`map'for nil:NilClass 您的意思是?挖掘在導軌中創建新產品時出現錯誤
產品控制器
<%= f.input :title , label: "Name of the product: " %>
<%= f.input :description, label: "Description of the product: " %>
<%= select_tag(:category_id, options_for_select(@categories), :promt => "Category")%>
<%= f.input :price, as: :integer , label: "Price of the product: " %>
<%= f.input :discount, label: "Discount for the product" %>
<%= f.input :image, as: :file,label: "Please upload image of the product" %>
這裏出現在控制檯錯誤
Cannot render console from 89.218.94.140! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by ProductsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"PSg52JmMvZq3dLjje4cEYuYe4ySr3v0DMx5pLv723KKYnQ0awd+ypWii+foe4c6HV6ddq1xEuyFMUwAgBNS0sA==", "product"=>{"title"=>"For her", "description"=>"Gentle and beauty", "price"=>"8000", "discount"=>"3300", "image"=>#<ActionDispatch::Http::UploadedFile:0x007fd3f0cd2140 @tempfile=#<Tempfile:/tmp/RackMultipart20170628-4090-3uc3bp.jpg>, @original_filename="705c9f06e0f2a2b960d54813b871e7eb.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"product[image]\"; filename=\"705c9f06e0f2a2b960d54813b871e7eb.jpg\"\r\nContent-Type: image/jpeg\r\n">, "available"=>"1"}, "category_id"=>"1", "commit"=>"Create Product"}
Command :: PATH=/usr/local/bin/:$PATH; file -b --mime '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-rlpn75.jpg'
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]' 2>/dev/null
Command :: PATH=/usr/local/bin/:$PATH; identify -format %m '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]'
Command :: PATH=/usr/local/bin/:$PATH; convert '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]' -auto-orient -resize "600x600>" '/tmp/a5967e19d796bb8d7db2a350531f598020170628-4090-7kuj4w'
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]' 2>/dev/null
Command :: PATH=/usr/local/bin/:$PATH; identify -format %m '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]'
Command :: PATH=/usr/local/bin/:$PATH; convert '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]' -auto-orient -resize "300x300>" '/tmp/a5967e19d796bb8d7db2a350531f598020170628-4090-zf5vc5'
Command :: PATH=/usr/local/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]' 2>/dev/null
Command :: PATH=/usr/local/bin/:$PATH; identify -format %m '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]'
Command :: PATH=/usr/local/bin/:$PATH; convert '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-9s8vu4.jpg[0]' -auto-orient -resize "150x" -crop "150x0+0+102" +repage '/tmp/a5967e19d796bb8d7db2a350531f598020170628-4090-1c398r8'
(0.1ms) begin transaction
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Command :: PATH=/usr/local/bin/:$PATH; file -b --mime '/tmp/65a151e5e2c95cb454ff8af39951145320170628-4090-fyglg3.jpg'
(0.1ms) rollback transaction
Rendering products/new.html.erb within layouts/application
Rendered products/_form.html.erb (5.9ms)
Rendered products/new.html.erb within layouts/application (7.0ms)
Completed 500 Internal Server Error in 346ms (ActiveRecord: 0.4ms)
你可以共享控制檯日誌以及產品控制器代碼 – Aashish
@Aashish 下面是產品控制器創建產品代碼: \t高清新 \t \t '@' 產品= Product.new \t \t '@' 類別= {Category.all.map | C | [c.name,c.id]} \t端 \t DEF創建 \t \t '@' 的產品= Product.new(product_params) \t \t'@'product.category_id =參數[:CATEGORY_ID] \t \t如果'@'product.save \t \t \t redirect_to的root_path \t \t其他 \t \t \t呈現 '新' \t \t結束 \t結束 和控制檯給出了同樣的錯誤: 無法呈現控制檯從89.218.94.140!允許的網絡:127.0.0.1,:: 1,127.0.0.0/127.255.255.255 –
請在問題本身中添加日誌。因此,任何閱讀您的問題的人都不需要閱讀評論部分以查找此日誌。 – RatDon