I was under the impression that comments were never allowed in ERB. For 
example:

$ ruby -v -rerb -e 'p ERB.new("<% 1 + 1 # test %>foo<% 1 + 1 %>bar").result'
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
2

That it worked in your example is an implementation detail.

Stephen Sykes wrote:
> I notice that ERB is still broken in Ruby 1.8.7.
>
> $ cat test.erb
> <% n=1 # make n equal to 1 %>
> something
> <% n=0 %>
> something else
> $ ruby -v
> ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0]
> $ erb test.erb
>
> something else
> $
>
> The comment in the ruby inside the <% %> seems to comment out all the
> non-ruby that follows, until the next <%.
>
> Compare with the old behaviour (on my other machine, but it doesn't matter):
>
> $ ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
> $ erb test.erb
> something
>
> something else
> $
>
> - Stephen
>
>
>