0
在這種模式下:在搜索加入域的思考 - 獅身人面像GET值導致
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'
我怎樣才能修理它?
我解決了這種方式:Product.search( 「東西」,:選擇=> 「產品*,category.name AS CATEGORY_NAME」:加入=> [:類]) – Sebtm 2012-04-24 07:57:54