ActionView::RoutingUrlFor
url_for
API docs (Rails 8.1.4.1) ↗def url_for(options = nil)
Description
Returns a URL as a string (only the path by default). Helpers such as link_to and button_to use it to build the URLs they are given.
This site renders with
GET /articles?page=2, shown above the ERB, as the current request. Besides a hash, it accepts:- A string: returned as is.
nil: the current request's path (/articles), without the query string.- A model object (
Article.find(1)), an array ([Article.find(1), comment]), a symbol (:articles) or a class (Article): finds the named route helper (such asarticle_path) from the routes and calls it. :back: the request'sRefererif present, otherwisejavascript:history.back().
ERB
Changes from the previous output: Added Removed Changed
Current request
GET /articles?page=2
HTML
Preview
Form submission
Form data
| name | value |
|---|
Request body
Content-Type:
params