最近我从这个讨论中了解了路由中的rails问题 如何在命名空间和根路径的路由中有一个资源--Rails 4.现在在我的应用程序中,我有这样的路线:
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'
Run Code Online (Sandbox Code Playgroud)
而且还有更多的资源在我需要的时候重复着.我知道如何实施它们.关心我可以这样做:
concern :shared_resources do
resources :photos
resources :businesses
resources :projects
resources :quotes
end
namespace :admin do
concerns :shared_resources
end
concerns :shared_resources
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能param在每次关注中给出不同的看法?我尝试这样做:
concerns :shared_resources, param: 'slug'
Run Code Online (Sandbox Code Playgroud)
但这并没有改变路线.如果我补充:
resources …Run Code Online (Sandbox Code Playgroud)