Spree多供应商市场控制器

问题描述 投票:1回答:1

我正在一个带有狂欢+多厂商市场宝石的小项目。我想创建一个索引并查看每个供应商,例如https://spree-multi-vendor-marketplace.com/vendorshttps://spree-multi-vendor-marketplace.com/vendors/c-amare#

这似乎不是很基本,这并不是插件的核心,这令人有点沮丧。

这是我第一次大礼包,我看不到控制器。我在文档中看不到如何生成它们,所以我创建了一个控制器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?” for Spree :: VendorsController:Class

ruby-on-rails spree
1个回答
0
投票

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

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

结束

我添加了内容,现在有一个索引页面。 :)我希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.