Arun Kumar Arun Kumar - 2 months ago 5x
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

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: