0

在我的 routes.rb 中,我有以下条目:-

  resources :products do  
    get 'get_products', :on => :collection
    get 'show_product_details',:on=>:member
    get 'buy_this',:on=>:collection
    get 'search_product',:on=>:collection 
  end 

我想将 URL 中的每个 /products 更改为 /eshop。我不确定,但我可以使用:path=>:eshop。它是否也适用于子路线,例如eshop/get_products,eshop/buy_this......等。

4

1 回答 1

0

您可以修改您的路线并在终端中运行 rake 路线以检查路径。

resources :products, :path => 'eshop', :as => 'eshop' do  
  get 'get_products', :on => :collection
  get 'show_product_details',:on=>:member
  get 'buy_this',:on=>:collection
  get 'search_product',:on=>:collection 
end

会产生这些

  get_products_eshop_index GET        /eshop/get_products(.:format)                              products#get_products
show_product_details_eshop GET        /eshop/:id/show_product_details(.:format)                  products#show_product_details
      buy_this_eshop_index GET        /eshop/buy_this(.:format)                                  products#buy_this
search_product_eshop_index GET        /eshop/search_product(.:format)                            products#search_product
               eshop_index GET        /eshop(.:format)                                           products#index
                           POST       /eshop(.:format)                                           products#create
                 new_eshop GET        /eshop/new(.:format)                                       products#new
                edit_eshop GET        /eshop/:id/edit(.:format)                                  products#edit
                     eshop GET        /eshop/:id(.:format)                                       products#show
                           PUT        /eshop/:id(.:format)                                       products#update
                           DELETE     /eshop/:id(.:format)                                       products#destroy
于 2013-05-13T08:33:29.617 回答