I am currently using link_to:
<%= link_to edit_webcast_path(@webcast), :class => 'btn' do %>
<i class="icon-pencil"></i> Edit Webcast
<% end %>
But I want to do the same with button_to, however button_to must have a first label argument passed to it or it will use the path as its label.
<%= button_to edit_webcast_path(@webcast), :class => 'btn' do %>
<i class="icon-pencil"></i> Edit Webcast
<% end %>
... results in a button with a label that is the resolved edit_webcast_path(@webcast) path. In effect do seems to have no effect.
I have tried passing html directly as the first argument:
<%= button_to "<i class=\"icon-white icon-minus-sign \"></i> Edit Webcast".html_safe, webcast_path(@webcast), :class => 'btn'%>
But this results in a button with the label displaying part of the html string I pass in. Looking at the generated HTMl I can see that the contents of this first argument is placed in the input's value attribute and not inside the input itself.
How can I get this to work?
Rails button_to
generates a form with html <input type="submit">
element , not <button>
one.
You can try to override it or write your own helper to generate <button>
, take a look at this example