Reputation: 888
very straight forward..
how do I add a class to something like this
<h2><%= guide.title %></h2>
which is just displaying text?
Upvotes: 1
Views: 301
Reputation: 44675
You have to wrap it within some container:
<div class="my_class"><%= guide.title %></div>
The container you'll use depends on the context given text is to be used.
Since the text is already wrapped in <h2>
you can do:
<h2 class='my_class'><%= guide.title %></h2>
If you wan to minimize the amount of pure html in your view, you can always do:
<%= content_tag :h2, class: 'my_class' do %>
<%= guide.title %>
<% end %>
Upvotes: 5