使用此模型:
class Product < ActiveRecord::Base
belongs_to :category
define_index do
join category
indexes sku
indexes category.name, :as => :category_name, :facet => true
end
end
当我做:
products = Product.search("something")
products[0].category_name if products.size > 0
我得到错误:
NoMethodError: undefined method `category_name'
我该如何解决?