1

What is the difference between :

<% @posts.each do |p| -%>
<%= p.title %>
<% end -%>

and

<% @posts.each do |p| %>
<%= p.title %>
<% end %>

and is there any ?

Cninroh
  • 1,796
  • 2
  • 21
  • 37

2 Answers2

2

-%> means that do not insert '\n' and whitespaces after the command.

kiddorails
  • 12,961
  • 2
  • 32
  • 41
-1

There is no difference.

"-%>" is completely useless in Rails 3.

Cninroh
  • 1,796
  • 2
  • 21
  • 37
  • you should provide a link to support that. – drewish Dec 05 '13 at 06:01
  • [ASCIIcasts seems to support this notion.](http://asciicasts.com/episodes/208-erb-blocks-in-rails-3) As does [this SO answer](http://stackoverflow.com/a/4407909/2540204). – neanderslob Nov 24 '14 at 23:23