UrlHelper
The UrlHelper
class provides methods for creating links inside of your Rails application,
letting you take advantage of the routing functionality Rails uses to manage addresses. (And
even though the REST world frequently talks about URIs rather than URLs, URLHelper
is the place to go to create both.)
button_to
Generates a form containing a single button that links to the specified controller. (Itâs the same as
url_for
, but wraps the result in a button.) You can ask users to confirm their interest after clicking the button.current_page?
Returns
true
if the current page has the same URL as the URL created by the options listed.link_to
Creates a link (
a
) element linking to the specified controller. (Itâs the same asurl_for
, but wraps the result in an HTML link.)link_to_if
Like
link_to
, but lets you specify conditions.link_to_unless
Like
link_to
, but lets you specify prohibitions.link_to_unless_current
Like
link_to
, but wonât link if the link is to the current page.mail_to
Creates a
mailto:
link to a given email address.url_for
Creates a URL based on the options provided and the Rails applicationâs routing table.
Get Learning Rails: Live Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.