Am a newbie to rails , please let me know the way to comment out a single line and also to comment out a block of lines in *.html.erb files.
To comment one line I must use 3 additional characters, and the block comment is nothing but code that will be not executed - no other color coding that makes it very unpractical to see which code is not executed on first look. @gotqn Then you will LOVE HAML!
%>\n <% end #____/\____/\____/\____%> . This makes the comment area obvious.
-- --> as a comment. As the other answers said, use <% #comment %> to comment within a Rails view.
The Ruby single-line comment begins with the # character and ends at the end of the line. Any characters from the # character to the end of the line are completely ignored by the Ruby interpreter.
ruby on rails notes has a very nice blogpost about commenting in erb-files
the short version is
to comment a single line use
<%# commented line %>
to comment a whole block use a if false
to surrond your code like this
<% if false %> code to comment <% end %>
Note that if you want to comment out a single line of printing erb you should do like this
<%#= ["Buck", "Papandreou"].join(" you ") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With