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

前端 未结 4 790
情歌与酒
情歌与酒 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

    And when used with the resources notation, it can be done like this:

    resources :post, 
                   only: [ :create, :index, :destroy ], 
                   constraints: { id: /[0-z\.]+/ }
    

    Tested in Rails 4.1

提交回复
热议问题