Search code examples
ruby-on-railsruby-on-rails-4ransackselect2-rails

Styling Ransack attribute_fields Select2 Rails plugin


I'm trying to style the select button from Ransack with the Select2 plugin.

  <%= f.attribute_fields do |a| %>
    <%= a.attribute_select %>
  <% end %>

That's generating and HTML output of:

<select id="q_c_0_a_0_name" name="q[c][0][a][0][name]">
  <option value=""></option>
  <option value="name">Name</option>
  <option value="points">Points</option>
  <option value="town_count">Town count</option>
  <option value="rank">Rank</option>
</select>

But somehow i can't find a way to assign to the attribute_fields the id 'select'

What am i missing?


Solution

  • Through Ransack_UI i found this:

    <%= f.attribute_fields do |a| %>
      <%= a.attribute_select({}, :id => 'select') %>
    <% end %>