2012-05-13 5 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 

.

그래서 수정 된 경로는 다음과 같이한다 : 나는 레일 3.2.1를 사용하고

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 

참고.

제공 할 수있는 도움이 있으면 대단히 감사하겠습니다.

답변

1

나는/저장소 네임 스페이스를 제거하기를 원한다는 것을 알고 있습니까?

namespace :product do 
    resources :home 
    resources :search 
end 

구조적인 이유가이 도움이

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

희망을 시도하기위한 네임 스페이스를 유지하려면

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

교체!

+0

이름을 바꾸고 싶습니다. product namespace to/products –

관련 문제