【问题标题】:Spree Multi Vendor Marketplace controllersSpree 多供应商市场控制器
【发布时间】:2020-06-06 05:46:30
【问题描述】:

我正在做一个带有 spree + 多供应商市场 gem 的小项目。我想为每个供应商创建一个索引和视图,例如https://spree-multi-vendor-marketplace.com/vendorshttps://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

【问题讨论】:

    标签: ruby-on-rails spree


    【解决方案1】:

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

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

    结束

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

    【讨论】:

      猜你喜欢
      • 2019-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-13
      • 2018-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多