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_toGenerates 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
trueif the current page has the same URL as the URL created by the options listed.link_toCreates 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_ifLike
link_to, but lets you specify conditions.link_to_unlessLike
link_to, but lets you specify prohibitions.link_to_unless_currentLike
link_to, but won’t link if the link is to the current page.mail_toCreates a
mailto:link to a given email address.url_forCreates a URL based on the options provided and the Rails application’s routing table.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access