Sha256: 5fe32ba9fce05d7991f4858efc61b05e459c47f1e69608e3c578bb70711dbad8

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

<% association = model.reflections[field.to_s] %>
<% if association %>
  <% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_id_in" %>
  <% desc = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %>
  <% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %>

  <%= form.label(label, class: 'filter-label') %>
  <% if options&.include? 'select' %>
    <%= form.select(field_key, nil, {}, multiple: true) do %>
      <%= options_from_collection_for_select(collection, :id, desc) %>
    <% end %>
  <% else %>
    <%= form.collection_check_boxes(field_key, collection, :id, desc) do |b| %>
      <%= b.label do %>
        <%= b.check_box %>
        <span><%= b.object.send(desc) %></span>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
administrate_ransack-0.6.0 app/views/administrate_ransack/components/_field_has_many.html.erb
administrate_ransack-0.5.1 app/views/administrate_ransack/components/_field_has_many.html.erb
administrate_ransack-0.5.0 app/views/administrate_ransack/components/_field_has_many.html.erb
administrate_ransack-0.4.1 app/views/administrate_ransack/components/_field_has_many.html.erb
administrate_ransack-0.4.0 app/views/administrate_ransack/components/_field_has_many.html.erb