我正在看这段代码,我可以看到它是actions: show and index
但是方法show和index在哪里?
http://github.com/railsdog/spree/blob/master/core/app/controllers/products_controller.rb
class ProductsController < Spree::BaseController
HTTP_REFERER_REGEXP = /^https?:\/\/[^\/]+\/t\/([a-z0-9\-\/]+\/)$/
#prepend_before_filter :reject_unknown_object, :only => [:show]
before_filter :load_data, :only => :show
resource_controller
helper :taxons
actions :show, :index
private
def load_data
load_object
@variants = Variant.active.find_all_by_product_id(@product.id,
:include => [:option_values, :images])
@product_properties = ProductProperty.find_all_by_product_id(@product.id,
:include => [:property])
@selected_variant = @variants.detect { |v| v.available? }
referer = request.env['HTTP_REFERER']
if referer && referer.match(HTTP_REFERER_REGEXP)
@taxon = Taxon.find_by_permalink($1)
end
end
def collection
@searcher = Spree::Config.searcher_class.new(params)
@products = @searcher.retrieve_products
end
def accurate_title
@product ? @product.name : nil
end
end
答案 0 :(得分:1)
我的猜测是actions
方法加载了resource_controller
作为lib目录中的模块。然后调用actions
方法创建索引并显示方法。
答案 1 :(得分:0)
该类继承自Spree :: BaseController和ActionController。 Spree :: BaseController有方法操作,它将方法名称作为消息。