ROR 中的 DRY 航线说明
我在 json Rest 应用程序中嵌套了路由组合,用于不同的下拉列表和分组
resources :cities, :only =>[:index,:show]
resources :regions, :only =>[:index,:show] do
resources :cities, :only=>[:index, :show]
end
resources :countries, :only=>[:index,:show] do
resources :cities, :only=>[:index,:show]
resources :regions, :only=>[:index,:show]
end
有没有一种方法可以更干燥地描述它?
I have nested combination of routes in json rest application used for different dropdown lists and grouping
resources :cities, :only =>[:index,:show]
resources :regions, :only =>[:index,:show] do
resources :cities, :only=>[:index, :show]
end
resources :countries, :only=>[:index,:show] do
resources :cities, :only=>[:index,:show]
resources :regions, :only=>[:index,:show]
end
Is there a way to describe it more DRY-way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实需要这些路线,我认为您无能为力。也许您可以使用 with_options 以更简洁的方式编写它:
If you actually need these routes I think you can't do very much about it. Probably you can just write it in a more concise way using with_options: