我知道在技术上可以通过使用约束来创建允许其中任何字符的路径。但是,我发现不可能创建在路径底部有一个点的路由,例如
http://localhost:5000/.well-known/acme-challenge/
这是我一直在使用的路线:
get ':my_root/acme-challenge/:id', to: 'pages#letsencrypt', constraints: {my_root: /.+/}
有人有什么想法吗?
最佳答案
看看dynamic-segments蓝色的你会发现
By default, dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment, add a constraint that overrides this – for example, id: /[^/]+/ allows anything except a slash.
你可以试试
获取 ':my_root/acme-challenge/:id',到:'pages#letsencrypt', Controller :/my_roo\/[^\/]+/
希望对你有帮助
关于ruby-on-rails - 如何创建路径底部带有点的 Rails 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36362545/