我想添加一个名为quick_view的方法,它基本上是一个show方法,但更简单,并且意味着在悬停在产品上时使用Ajax。
我怎样才能做到这一点?如何打开spree的ProductsController并添加before_filters并指定适当的路径..
谢谢!
答案 0 :(得分:1)
Doco for that is at https://guides.spreecommerce.com/developer/logic.html
Create a class called app/controllers/products_controller_decorator.rb
, and put something like this in it:
Spree::ProductsController.class_eval do
before_filter :my_filter, :only => :quick_view
def quick_view
# your code goes here
end
private
def my_filter
# code for your before filter goes here
end
end
As for the routes, you'll be able to add it in your routes.rb
file just like any other route, but you'll need to specify that it's a spree route:
Spree::Core::Engine.routes.draw do
# Your route goes inside this block
end