向Rails的狂欢电子商务添加路由

我刚刚升级到1.0.3 ,我的config / routes文件夹中的routes.rb文件似乎忽略了我的所有自定义路由。

我的routes.rb

 JollyStore::Application.routes.draw do # Mount Spree's routes mount Spree::Core::Engine, :at => '/' root :to => 'pages#index' namespace :admin do resources :wysiwygs end match 'about_us/', :to => "pages#about_us" match 'services/', :to => "pages#services" match 'raw_resources/', :to => "pages#raw_resources" match 'contact_us/', :to => "pages#contact_us" match 'privacy_policy/', :to => "pages#privacy_policy" match 'return_policy/', :to => "pages#return_policy" match 'refund_policy/', :to => "pages#refund_policy" match 'cancellation_policy/', :to => "pages#cancellation_policy" match 'delivery_shipping_policy/', :to => "pages#delivery_shipping_policy" end 

如果我运行bundle exec rake routes ,它将返回所有approriate路由。 但当我尝试访问该特定页面时,我得到:

 undefined local variable or method `about_us_path' 

或者我的自定义路由中的每个链接都有相同的错误。 不知怎的,我的路线被忽略了。 有没有人知道绕过这个问题的方法?

我遇到了同样的错误并找到了这个解决方案 ,它通过在每个my_paths/_urls之前添加main_app前缀来解决它。 在我的例子中,这些是在其中一个/override.rb文件中使用的链接。

所以,试试: main_app.about_us_path

您可以使用routes.rb文件中的以下块在Spree中添加新路由

 Spree::Core::Engine.routes.prepend do # Your new routes end 

对我来说,前置不起作用。 为我画画做了工作:

 Spree::Core::Engine.routes.draw do resources :orders, except: [:new, :create, :destroy] do post :my_order, on: :collection end end