开发者

How to create a conditional route

开发者 https://www.devze.com 2023-03-11 19:19 出处:网络
how can I create a conditional route that work for the following: http://site.com/1vcs1YUf1Z Where 1vcs1YUf1Z is a UID.

how can I create a conditional route that work for the following:

http://site.com/1vcs1YUf1Z

Where 1vcs1YUf1Z is a UID.

Is there a way I can add a routing option to the end of my route file that says if the following condition is met (10 characters trailing the first / and that's it) then to route to the开发者_开发百科 following and pass that as the UID?

Thanks


get 'projects/:uid' => 'controller#action',
  :constraints => { :uid => /^[0-9a-z]{10}$/i }
0

精彩评论

暂无评论...
验证码 换一张
取 消