Should I be using the content_tag helper for all html tags when working with Rails?
Is it The Rails Way to use content_tag for even simple things like Header tags?
<%= content_tag :h2, :class => "bla bla" do %>
Header
<% end %>
vs.
<h2>Header</h2>
Clearly just using straight html is much ‘simpler’ and ‘shorter’, but what is the correct Rails Way of doing things?
Using
content_tagwhen you don’t have to is a waste. There’s no need to use ERBisms to generate static HTML so don’t do it. If some other piece of code determines what tag to use, then you’d usecontent_tagto construct that tag.