如何在routes.rb中编写匹配关键字

时间:2014-05-27 09:45:59

标签: ruby-on-rails ruby-on-rails-4

http://localhost:4500/clients/client_show?mac_id=f8:e0:79:9b:bb:58&nas_id=00:11:22:33:44:55

我想将此网址转换为

http://localhost:4500/clients/client_show/f8:e0:79:9b:bb:58/00:11:22:33:44:55

为此我如何在routes.rb中编写路径,提前谢谢..

2 个答案:

答案 0 :(得分:1)

遵循这种模式:

match 'photos', to: 'photos#show', via: [:get, :post]
希望有所帮助。

答案 1 :(得分:0)

get '/clients/client_show/:mac_id/:nas_id', to: 'clients#client_show'

然后您可以通过

访问它
params[:mac_id] and params[:nas_id]