Arun Kumar Arun Kumar - 3 months ago 13
Ruby Question

Rails - Using Font Awesome

How to include a font awesome icon code within my button?

<%=f.submit "Post",class: "btn btn-primary btn-large" %>


I tried this :

<%=f.submit '<i class="icon-ok icon-white"></i>Post'.html_safe,class: "btn btn-primary btn-large"%>


But it shows up like this:

!(http://tinypic.com/view.php?pic=2wgrojt&s=8#.U6II3N9d4so)

I am a beginner and any help would be great.

Jon Jon
Answer

If you're using Rails 4, you can pass a block to the submit method and include your HTML in there.

Try this:

<%= f.submit class: 'btn btn-primary btn-large' do %>
  <i class="icon-ok icon-white"></i> Post ...
<% end %>

See this GitHub issue for more details: https://github.com/plataformatec/simple_form/issues/745

Comments