How to add Bootstrap class to Ransack form_for

98 Views Asked by At

In views/articles/index.html.erb:

<%= search_form_for  @q  do |f| %>
  <%= f.label :title %>
  <%= f.search_field :title_or_body_cont_any %>
  <%= f.submit %>
<% end %>

I tried add class="btn btn-primary" to submit:

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

but I get error. How can I join Bootstrap class to form_for field?

1

There are 1 best solutions below

7
mechnicov On

Apparently, search_form_for is usual form wrapper

Therefore it's usual submit and it's enough to pass class as option:

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