Rails — Params with “dot” (e.g. /google.com)

前端 未结 4 792
情歌与酒
情歌与酒 2020-12-09 04:02

How to force Rails to consider a param with a dot in the value like google.com (e.g. /some_action/google.com) a single param and not \"id\" =

4条回答
  •  半阙折子戏
    2020-12-09 04:14

    In Rails 4 I used:

    get 'operation/:p1/:p2', to: 'operation#get', constraints: { p1: /[^\/]+/, p2: /[^\/]+/ }
    

    it allows any character in both params (other than '/')

提交回复
热议问题