Provides a set of methods for making links and getting URLs that depend on
the routing subsystem (see ActionController::Routing). This allows you to
use the same format for links in views and controllers.
| Public Methods |
| button_to |
Generates a form containing a single button that submits to the URL created
by the set of options. This is the safest method to ensure links
that cause changes to your data are not triggered by search bots or
accelerators. If the HTML button does not work with your layout, you can
also consider using the link_to method with the :method modifier
as described in the link_to documentation.
|
| current_page? |
True if the current request URI was generated by the given
options.
|
| link_to |
Creates a link tag of the given name using a URL created by the
set of options. See the valid options in the documentation for
url_for. It’s also possible to pass a string instead of an options
hash to get a link tag that uses the value of the string as the href for
the link, or use +:back+ to link to the referrer - a JavaScript back link
will be used in place of a referrer if none exists. If nil is passed as a
name, the link itself will become the name.
|
| link_to_if |
Creates a link tag of the given name using a URL created by the
set of options if condition is true, in which case only
the name is returned. To specialize the default behavior, you can pass a
block that accepts the name or the full argument list for link_to_unless
(see the examples in link_to_unless).
|
| link_to_unless |
Creates a link tag of the given name using a URL created by the
set of options unless condition is true, in which case
only the name is returned. To specialize the default behavior (i.e., show a
login link rather than just the plaintext link text), you can pass a block
that accepts the name or the full argument list for link_to_unless.
|
| link_to_unless_current |
Creates a link tag of the given name using a URL created by the
set of options unless the current request URI is the same as the
links, in which case only the name is returned (or the given block is
yielded, if one exists). You can give link_to_unless_current a block which
will specialize the default behavior (e.g., show a "Start Here"
link rather than the link’s text).
|
| mail_to |
Creates a mailto link tag to the specified email_address, which is
also used as the name of the link unless name is specified.
Additional HTML attributes for the link can be passed in
html_options.
|
| url_for |
Returns the URL for the set of options provided. This takes the
same options as url_for in ActionController (see the documentation for
ActionController::Base#url_for). Note that by default :only_path
is true so you’ll get the relative /controller/action
instead of the fully qualified URL like example.com/controller/action.
|
<code/>and<pre/>for code samples.