Named routes _path vs _url

前端 未结 4 2061
借酒劲吻你
借酒劲吻你 2020-11-29 20:27

Rails provides named routes.

Routes helper can be called using path or url

eg from docs:

# and provide these named routes
root_url   # =>          


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 20:34

    As the other answers explain, you should use _url in email links, etc. But I would like to add that you should also use _url in redirects, as explained here:

    https://www.ruby-forum.com/topic/101346#221052

    and, here:

    http://viget.com/extend/rails-named-routes-path-vs-url

    You can also take a look at the relevant section of the HTTP specification here:

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

提交回复
热议问题