Ruby-on-rails – the meaning of “h” in “<%=h [ ...] %>“


When I generate a default scaffold, the display tags on show.html.erb have

<%=h %>

I know the difference between <% and <%=. What's the "h" do?

Best Solution

html escape. It's a method that converts things like < and > into numerical character references so that rendering won't break your html.