Recently I got to know about rails concerns in routes from this discussion How to have one resource in routes for namespace and root path altogether - Rails 4. Now in my application I have routes like this:
namespace :admin do
resources :photos
resources :businesses
resources :projects
resources :quotes
end
resources :photos, param: 'slug'
resources :businesses, param: 'slug' do
resources :projects, param: 'slug' #As I need both the url one inside business and one outside
end
resources :projects, param: 'slug'
resources :quotes, param: 'slug'
And there are many more resources which are repeating as I needed them. I know about concerns how to implement them. With the concerns I can do it like this:
concern :shared_resources do
resources :photos
resources :businesses
resources :projects
resources :quotes
end
namespace :admin do
concerns :shared_resources
end
concerns :shared_resources
but how can I give different param
each time in the concerns? I tried doing it like this:
concerns :shared_resources, param: 'slug'
But this brings no change in the routes. And if I add:
resources :photos, param: 'slug'
Then it will add to both the routes slug instead of id. But in admin side I need id and in front end I need slug. So are there any options to pass this in the concerns so to DRY up the code.