Rails Tags

There are two variations on the Rails tags that you can place into Rails HTML Embedded Ruby (ERb) template files. The ones you’ve used so far include an equal sign in the opening delimiter: <%=.

These tags cause Rails not only to evaluate Ruby expressions but also to display the results in a web page. If you omit the equals sign from the opening delimiter, then the code will be evaluated, but the result will not be displayed: <%.

Note

ERb files contain a mix of HTML markup and Ruby code between tags such as <%= and %>. Rails processes these files before the final pages are displayed in the web browser, executing the embedded Ruby and constructing the HTML page as a result.

If you want, you can place quite long pieces of code—your entire ...

Get The Book of Ruby 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.