2012-05-13 4 views
0

Я немного новый с Rails (3.) и вам нужна ваша помощь, чтобы использовать переименованные маршруты. У меня есть следующие маршруты для отображения и поиска продуктов.Rails 3.2.1 - маршруты переименования

namespace :store do 
    namespace :product do 
     resources :home 
     resources :search 
    end 
    end 

rake routes И делает следующий вывод для указанных ресурсов:

store_product_home_index GET /store/product/home(.:format)      store/product/home#index 
          POST /store/product/home(.:format)      store/product/home#create 
    new_store_product_home GET /store/product/home/new(.:format)     store/product/home#new 
    edit_store_product_home GET /store/product/home/:id/edit(.:format)    store/product/home#edit 
     store_product_home GET /store/product/home/:id(.:format)     store/product/home#show 
          PUT /store/product/home/:id(.:format)     store/product/home#update 
         DELETE /store/product/home/:id(.:format)     store/product/home#destroy 
store_product_search_index GET /store/product/search(.:format)      store/product/search#index 
          POST /store/product/search(.:format)      store/product/search#create 
    new_store_product_search GET /store/product/search/new(.:format)     store/product/search#new 
edit_store_product_search GET /store/product/search/:id/edit(.:format)   store/product/search#edit 
     store_product_search GET /store/product/search/:id(.:format)     store/product/search#show 
          PUT /store/product/search/:id(.:format)     store/product/search#update 
         DELETE /store/product/search/:id(.:format)     store/product/search#destroy 

Вместо того, чтобы путь/магазина/продукта/дома, я хотел бы переименовать в/продукции/дома.

Так модифицированные маршруты должны выглядеть следующим образом:

store_product_home_index GET /products/home(.:format)      store/product/home#index 
          POST /products/home(.:format)      store/product/home#create 
    new_store_product_home GET /products/home/new(.:format)     store/product/home#new 
    edit_store_product_home GET /products/home/:id/edit(.:format)    store/product/home#edit 
     store_product_home GET /products/home/:id(.:format)     store/product/home#show 
          PUT /products/home/:id(.:format)     store/product/home#update 
         DELETE /products/home/:id(.:format)     store/product/home#destroy 
store_product_search_index GET /products/search(.:format)      store/product/search#index 
          POST /products/search(.:format)      store/product/search#create 
    new_store_product_search GET /products/search/new(.:format)     store/product/search#new 
edit_store_product_search GET /products/search/:id/edit(.:format)   store/product/search#edit 
     store_product_search GET /products/search/:id(.:format)     store/product/search#show 
          PUT /products/search/:id(.:format)     store/product/search#update 
         DELETE /products/search/:id(.:format)     store/product/search#destroy 

Обратите внимание, что я использую Rails 3.2.1.

Любая помощь, которую вы можете предоставить, очень ценится.

ответ

1

Как я понимаю, вы просто хотите, чтобы пространство имен/store было удалено?

заменить

namespace :store do 
    namespace :product do 
     resources :home 
     resources :search 
    end 
    end 

с

namespace :product do 
    resources :home 
    resources :search 
end 

если вы хотите сохранить пространство имен для структурных причин попробовать

namespace :store,:path => "" do 
    namespace :product do 
     resources :home 
     resources :search 
    end 
    end 

надеюсь, что это помогает!

+0

Я также хочу переименовать: пространство имен продуктов в/products –

Смежные вопросы