views:

159

answers:

1

I'm new to Ruby on Rails and am working my way through the tutorial posted here: http://www.tutorialspoint.com/ruby-on-rails/index.htm

One of the questions I have is that I see this used sparingly throughout the code samples:

<%= link_to c.title, {:action => 'show', :id => c.id} -%>

Where other times, I see this:

<%= link_to 'Edit', {:action => 'edit', :id => c.id} %>

Specifically, I'm wondering if there is a reason for that minus sign (-) before the closing %> or if its just a typo on behalf of the author.

On a side note, I've tried searching google and SO for similar questions, but -%> isn't exactly a google friendly search term.

+3  A: 

A dash either immediately after the opening tag (<%-) or immediately before the closing tag (-%>) trims all whitespace before or after the tag, respectively. The most common use, such as you reference above, is to use -%> to avoid inserting a newline after the code.

Pesto
That makes perfect sense, and it was very easy to verify. Thanks!
jerhinesmith