路线上的正则表达式

时间:2012-06-01 12:35:22

标签: ruby-on-rails regex routing

我有这样的路线

  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

我想我会有更多行动,而且我不想继续在我的路线上添加match 有没有办法做类似

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

1 个答案:

答案 0 :(得分:3)

当然,像一个默认路线放一个占位符:

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

不需要正则表达式。请参阅Rails路由文档的Dynamic Segments portion

相关问题