如何使用狂欢轨在控制器内部创建方法?

时间:2018-07-13 10:16:18

标签: model-view-controller ruby-on-rails-5 spree

Screenshot of Error Message

内部:-config / routes.rb

Rails.application.routes.draw do

  mount Spree::Core::Engine, at: '/'
  Spree::Core::Engine.add_routes do
  namespace :api, :defaults => { :format => 'json' } do
    resources :option_values
  end
end
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

 Spree::Core::Engine.routes.draw do
   namespace :admin, path: Spree.admin_path do

  get 'masterlist' => 'products#masterlist'
  end
end

内部:-controller / spree / admin / product_controller.rb

module Spree
  Spree::ProductsController.class_eval do

   def masterlist
 session[:return_to] = request.url
        respond_with(@collection)
   end

  end
end

0 个答案:

没有答案