rails 里xxx_path和xxx_url的区别

rails 里xxx_path和xxx_url的区别
path是相对路径 url是绝对路径
例子
users_url # => http://localhost:3000/users
users_path # => /users

参考http://stackoverflow.com/questions/2350539/what-is-the-difference-between-url-and-path-while-using-the-routes-in-rails
_path are 是针对 views的,因为a标签包含了当前页面的路径,所以不需要全路径,这样可以减少字符数量从而节省带宽,在controller里用和 redirect_to配合使用*_url

rails 里xxx_path和xxx_url的区别
path是相对路径 url是绝对路径
例子
users_url # => http://localhost:3000/users
users_path # => /users

参考http://stackoverflow.com/questions/2350539/what-is-the-difference-between-url-and-path-while-using-the-routes-in-rails
_path are 是针对 views的,因为a标签包含了当前页面的路径,所以不需要全路径,这样可以减少字符数量从而节省带宽,在controller里用和 redirect_to配合使用*_url