Spree 多供应商市场控制器

Spree Multi Vendor Marketplace controllers

我正在做一个带有 spree + 多供应商市场的小项目 gem。我想为每个供应商创建一个索引和视图,例如 https://spree-multi-vendor-marketplace.com/vendors and https://spree-multi-vendor-marketplace.com/vendors/c-amare#

这不是插件的核心,这有点令人沮丧,因为它看起来很基础。

我是第一次玩spree,看不到手柄。我看不到如何在文档中生成它们所以我创建了一个控制器 app/controllers/spree/vendors_controller.rb

module Spree
  class VendorsController
    def index
    end
    def show
    end
  end
end

我在config/routes.rb

中添加了路线
Rails.application.routes.draw do
  # This line mounts Spree's routes at the root of your application.
  # This means, any requests to URLs such as /products, will go to
  # Spree::ProductsController.
  # If you would like to change where this engine is mounted, simply change the
  # :at option to something different.
  #
  # We ask that you don't use the :as option here, as Spree relies on it being
  # the default of "spree".
  mount Spree::Core::Engine, at: '/'
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

Spree::Core::Engine.routes.draw do
  resources :vendors 
end

我添加了一个空白视图用于测试 app/views/spree/vendors/index。html.erb

现在我得到未定义的方法 `binary_params_for?' Spree::VendorsController:Class

spree 多供应商使用商店控制器,因此我们必须在我们的控制器中调用它。

module Spree
  class VendorsController < Spree::StoreController
    def index
      @vendors = Spree::Vendor.all
    end
    def show
    end
  end

结束

我添加了它,现在我有了一个索引页。 :) 希望对您有所帮助