Static nested resource params name on Rails routes -


i'm playing on rails routing can't figure out how manage this. problem @ user_posts(1) , user(4) routes, params have different names - id , user_id

what i'm trying achieve static param name same resource.

i have route file

rails.application.routes.draw   shallow     resources :users, module: :users, only: [:index, :show]       resources :posts, module: :posts, only: [:index, :show]     end   end end 

the routes generated are

   user_posts(1)  /users/:user_id/posts(.:format)      users/posts/posts#index    post(2)        /posts/:id(.:format)                 users/posts/posts#show    users(3)       /users(.:format)                     users/users#index    user(4)        /users/:id(.:format)                 users/users#show 

i tried resources :user param: :user generated route @ user_posts /users/:user_user_id/posts

is possible achieve :user_id param , :post_id param every route using resources?

try this

resources :users, param: :user_id resources :users, only: []     resources :posts, param: :post_id end 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -