0
ActionView::Template::Error (undefined method `default_image' for nil:NilClass): 409: 410: <!-- Image --> 411: <div class="image"> 412: <% if @product.default_image %> 413: 414: <a href="#" class="main"><%= image_tag @product.default_image.path, :weight => '262px',:height => '197px'%></a> 415: <% end %>
模型:未定義的方法`default_image」的零:NilClass
# Return attachment for the default_image role
#
# @return [String]
def default_image
self.attachments.for("default_image")
end
# Set attachment for the default_image role
def default_image_file=(file)
self.attachments.build(file: file, role: 'default_image')
end
控制器:
class ProductsController < ApplicationController
def index
@products = Shoppe::Product.root.ordered.includes(:product_categories, :variants)
@products = @products.group_by(&:product_category)
@product = Shoppe::Product.root.find_by_permalink(params[:permalink])
@order = Shoppe::Order.find(current_order.id)
end
end