regex on routes

烈酒焚心 提交于 2019-12-11 10:52:17

问题


I have routes like this

  namespace :api, defaults: {format: 'json'} do
    namespace :v1 do
      match 'recepcao/produto' => 'recepcoes#produto'
      match 'recepcao/nota'    => 'recepcoes#nota'
      match 'recepcao/venda'   => 'recepcoes#venda'
      match 'recepcao/cliente' => 'recepcoes#cliente'
      match 'recepcao/status' => 'recepcoes#status'
    end
  end

I guess I'll have more actions, and i don't want to keep adding matchon my routes
is there a way to do something like

  namespace :api, defaults: {format: 'json'} do
    namespace :v1 do
      match 'recepcao/*' => 'recepcoes#*'
    end
  end

回答1:


Of course, put a placeholder like the default route:

# match ':controller(/:action(/:id(.:format)))'

No need for a regex. See the Dynamic Segments portion of the Rails routing docs.



来源:https://stackoverflow.com/questions/10850381/regex-on-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!