Spree多供应商市场控制器

时间:2020-06-06 05:46:30

标签: ruby-on-rails spree

我正在开发一个带有狂欢+多供应商市场宝石的小项目。我想为每个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?”。对于Spree :: VendorsController:Class

1 个答案:

答案 0 :(得分:1)

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

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

结束

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