问题
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 match
on 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