October 6

0 comments

A quick way to remark out code in a rails view

By Christopher Mendla

October 6, 2016


Last Updated on November 30, 2019 by Christopher G Mendla

There are times when I want to remark out code in a rails view for testing purposes.

I tried using the =begin / =end that can be used in a controller but I couldn’t get that to work. i.e

<% begin %>
<% end %>

I did find a solution with the following

<% pigs = ‘notfly’ %> 
<% if pigs==’fly’ then %>
( Code you are remarking out)
<% end    # pigs%>

Simply put, you set a variable called pigs and set that to notfly. You then put a conditional looking for pigs set to ‘fly’. Since you set it above, the condition fails and the code is skipped,

I also use a remark in the end statement to make it easy to find and delete when I’m done trouble shooting.

Christopher Mendla

About the author

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}