Named routes _path vs _url

前端 未结 4 2055
借酒劲吻你
借酒劲吻你 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

    _path helpers provide a site-root-relative path. You should probably use this most of the time.

    _url helpers provide an absolute path, including protocol and server name. I've found that I mainly use these in emails when creating links to the app on the server. They should mainly be used when providing links for external use. (Think email links, RSS, and things like the copy and paste URL field under a YouTube video's "Share" section.)

提交回复
热议问题