this is what works with button_to
<%= button_to random_joke_path, {remote: true, class: "btn btn-small"} do %>
Następny <i class="icon-play"></i>
<% end %>
Question
If you look at the image of my app below, you'd see that first button has no glyph icon (the play icon) and second but does. Can someone please help me with putting a glyph icon in the first button just as in the button below?
This post Adding Bootstrap icon to button in Ruby on Rails and this Using link_to with embedded HTML didn't work for me. This is the code for the first and second buttons:
<div>
<blockquote class="pull-left">
<p id="joke_section">
<%= @l.content %>
</p>
<small><%= @l.author %> </small>
<%= button_to "Następny", random_joke_path, {remote: true, class: "btn btn-small"} %>
</blockquote>
</div>
</div>
</div>
<div><blockquote class="pull-left">
<p id="mycontainer"><%= @l.content %> </p>
<small><%= @l.author %> </small>
<button id="but" class="btn btn-small", "pull=right" type="button">
Następny <i class="icon-play"></i>
</button>
</blockquote></div>
Solution
this is what works with button_to
<%= button_to random_joke_path, {remote: true, class: "btn btn-small"} do %>
Następny <i class="icon-play"></i>
<% end %>
OTHER TIPS
you're using bootstrap 2? so you see that <i class="icon-play"></i>
? That class is what gets the image in there. so in your rails code...
<%= link_to random_joke_path, class: "btn btn-small", remote: true do %>
Następny <i class="icon-play"></i>
<% end %>
I think that will work for you.