I am trying to find full documentation about the way to embed ruby
commands in the rails views.
I am working on a large existing app. We just installed Ruby 1.8.7 on
one of our servers in an attempt to get cruisecontrol.rb working with
metrics_fu.
It seems that this version of ruby does not like comments in the
embedded ruby in the rails views.
So I am looking through the app, and there are various things in our
views, such as:
<%= # comment about %>
<%# comment about stuff around this line %>
<%= # commented out code %>
<% end # comment about what it is ending %>
And the new ruby does not seem to like any of these. It seems as
though the %> gets commented out as well.
There is also one other thing I could not find documentation for:
<%- -%>
Notice the dashes! Do they do anything? Or is it just that you can
put dashes and it won’t really affect anything (besides perhaps the
return value.
So I am looking through the app, and there are various things in our
views, such as:
<%= # comment about %>
<%# comment about stuff around this line %>
<%= # commented out code %>
<% end # comment about what it is ending %>
erb in ruby 1.8.7 slightly changed behaviour of what had been
previously undefined behaviour (ie it just happened to work before but
never documented as such), namely
<%# is ok
but <% bla bla #
and variants thereof aren’t
And the new ruby does not seem to like any of these. It seems as
though the %> gets commented out as well.
There is also one other thing I could not find documentation for:
<%- -%>
Notice the dashes! Do they do anything? Or is it just that you can
put dashes and it won’t really affect anything (besides perhaps the
return value.
You may be able to come with a regexp that you can use for a global
search/replace.
You possibly want to replace all <%somecode#somecomment%> with
<%somecode%><%#somecomment%> though there will no doubt be some
special cases.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.