Arun Kumar Arun Kumar - 1 year ago 114
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:


I am a beginner and any help would be great.

Jon Jon
Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download