I want to print out some debug messages in my erb template when it is called in development mode, but not when it is called in production mode (i.e.)
<%= debug variable_name %>
However, this will be printed in any mode.
I found I can do
<% if logger.debug?
debug variable_name
end %>
which seems to work. Is this the proper way, or is there a more elegant solution?
You probably want to do something like this:
If you’re doing this often, you might want to create a quick helper method to clean up the code a little more:
Then you can do this in your erb template/view