I want to make a route like this /p/:id/:ph_id
. and the :ph_id
also has limitation on length /\d{7}/
我想做一条这样的路线/p/:id/:ph_id。并且:ph_id也有长度/\d{7} /。
This is what I have for the first id
这是第一个id
scope '/p', :controller => 'people' do
scope '/:id', :id => /\d{7}/ do end
end
1 个解决方案
#1
7
In your config/routes.rb
try following code:
在你的配置/路线。rb尝试以下代码:
get "/p/:id/:ph_id" => "people#show", as: :my_route, id: /\d{7}/, ph_id: /\d{7}/
You can use it like:
你可以这样使用:
<%= link_to "Check this link!", my_route_path(id: 1234567, ph_id: 7654321) %>
Hope that helps! Good Luck!
希望会有帮助!好运!
#1
7
In your config/routes.rb
try following code:
在你的配置/路线。rb尝试以下代码:
get "/p/:id/:ph_id" => "people#show", as: :my_route, id: /\d{7}/, ph_id: /\d{7}/
You can use it like:
你可以这样使用:
<%= link_to "Check this link!", my_route_path(id: 1234567, ph_id: 7654321) %>
Hope that helps! Good Luck!
希望会有帮助!好运!