Ruby on rails 3 Spree商务产品分类
我有一个spree commerce rails应用程序,我想在前端添加一些用户控制的产品排序,在产品范围内已经定义了一些简单的范围,但我不确定如何在视图中显示它们 现在只要简单的链接就足够了,然后我可以扩展 这里是我可以使用的开箱即用的范围,为链接道歉,但它太多了,无法复制和粘贴Ruby on rails 3 Spree商务产品分类,ruby-on-rails-3,spree,Ruby On Rails 3,Spree,我有一个spree commerce rails应用程序,我想在前端添加一些用户控制的产品排序,在产品范围内已经定义了一些简单的范围,但我不确定如何在视图中显示它们 现在只要简单的链接就足够了,然后我可以扩展 这里是我可以使用的开箱即用的范围,为链接道歉,但它太多了,无法复制和粘贴 app/models/spree/product\u sorting\u decorator.rb module Spree Product.class_eval do attr_
app/models/spree/product\u sorting\u decorator.rb
module Spree
Product.class_eval do
attr_accessible :variable_1, :variable_2,
:variable_3, :variable_4, :as => [:default, :user]
def put_your_sorting_method_here
#your logic goes here
end
end
end
让我们覆盖控制器:
app/controllers/spree/products\u controller.rb
Spree::ProductsController.class_eval do
def sorting_action
#your logic goes here and get the sorted list of product @product
# by accessing the method defined in model file
end
end
在查看页面(products/index.html.erb)中:
这里只需通过标记行:remote=>true来调用控制器操作,并使用@product作为产品的排序列表